Waqf (Islamic endowment) is a kind of ongoing charity (sadaqah jaariyah) for which those who set them up will be rewarded. It is one of the deeds for which the reward will reach the believer in his grave.
It was narrated that Abu Hurayrah (may Allaah be pleased with him) said: The Messenger of Allaah (peace and blessings of Allaah be upon him) said: “Among the good deeds that will reach a believer after his death are: knowledge which he learned and then spread; a righteous son whom he leaves behind; a copy of the Qur’aan that he leaves as a legacy; a mosque that he built; a house that he built for wayfarers; a canal that he dug; or charity that he gave during his lifetime when he was in good health. These deeds will reach him after his death.” Narrated by Ibn Maajah, 242; classed as hasan by al-Albaani in Saheeh al-Targheeb, 77.
With regard to lending these books, reference should be made to the conditions stipulated by the one who donated them as a waqf. If he gave permission for lending them to those who will benefit from them and then return them, or if he did not stipulate that but it is customary for people to borrow the books that have been donated as a waqf to the mosque, then in these two cases there is nothing wrong with lending them.
The one who is responsible for them should document this lending by writing down the name of the borrower and noting the date the book was borrowed and the date for its return.
The one who borrows a book has to look after it and guard against any tearing or damage, and not write in it. He must return it on the date stipulated, so that others will also have the opportunity to benefit from it, and the reward for the one who donated it will be increased.
But if the donor stipulated that they should not be lent out, or he did not stipulate anything and it is not customary for people to borrow books, then it is not permissible to lend them to anyone, and whoever wants to benefit from them has to read them in the mosque.
With regard to disposing of them, the one who is in charge of the waqf should act in accordance with the conditions stipulated by the one who donated the waqf, with regard to lending them or not lending them, and other conditions.
It is not permissible for him to let small children or those who are known to be careless and not look after them get hold of them, because that is a betrayal of the trust for which he is responsible.
For more information on the rulings on waqfs, please see the answer to question no. 13720.
And Allaah knows best.