Fiqh-us-Sunnah Volume 2, Supererogatory Prayer, Fiqh 2.027.

Section : The legality of the Tarawih prayer.

The specific prayers during the month of Ramadan, which are known as tarawih, are sunnah for both men and women, and they are to be performed after the obligatory ‘isha and before the performance of the witr. They should be prayed in sets of two rak’at each. It is allowed to pray them after witr; though, this is not the best thing to do. They may be performed until the end of the night.

Abu Hurairah reports that the Prophet sallallahu alehi wasallam would encourage people to perform the special prayers during Ramadan without commanding them as obligatory and he said: “Whoever prays during the nights of Ramadan [tarawih] with a firm belief and hoping for reward, all of his previous sins would be forgiven.” This is related by the group.

‘Aishah says: “The Prophet offered salah in the mosque and many people prayed with him. The next day he did the same and more people prayed with him. Then the people gathered on the third night but, the Prophet did not come out to them. In the morning, he said to them: ‘Surely I saw what you did, and nothing prevented me from coming out to you, save that I feared that [that prayer] would be made obligatory upon you.’ And that was during Ramadan.” This is related by the group except for at-Tirmizhi.