All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu ‘alayhi wa sallam, is His Slave and Messenger.
The mosque is not a place for buying and selling as the Prophet, sallallaahu ‘alayhi wa sallam, said: “When you see someone buying or selling in the mosque, say to him, May Allaah not make your trade profitable.” [At-Tirmithi graded it Hasan (good)]
Hence, it is impermissible to sell anything inside the mosque, be it religious books or anything else, whether there are proper conditions or not, and whether at a profit or at the cost price. You should not sell anything in the mosque in order to avoid this prohibition. Thank Allaah, the matter is simple, as you can sell these books at the door of the mosque or outside it in a nearby place.
Allaah Knows best.