Thus the Prophet, peace and blessings be upon him, encouraged the night prayer of Ramadan without imposing it as an obligation; it was not compulsory, but he urged it, saying: “Whoever spends the nights of Ramadan in prayer, motivated by faith and seeking reward, will have his past sins forgiven.”
He led his Companions in congregational prayer for three nights of Ramadan, then refrained and said, “I feared that it might be made obligatory for you and that you would be unable to fulfill it.” After that, people continued coming to the mosque and prayed in small groups—two together, three together—each group following its own companion. One night ʿUmar went out and found them praying in scattered groups. With his keen foresight he decided to unite them behind a single imam, so he instructed Ubayy ibn Kaʿb, along with another Companion, to lead the people in eleven rakʿahs. The worshippers thus gathered behind one imam for the tarawih, and Muslims have remained upon this practice up to the present day.
The scholars, however, have differed over the number of rakʿahs in tarawih: some say eleven, others thirteen, others twenty-three, and some allow even more. The matter is spacious, for the early generations who disagreed did not censure one another. Accordingly, we do not criticize anyone who exceeds eleven rakʿahs, nor anyone who exceeds twenty-three.
Our advice is: pray as many rakʿahs as you wish, provided the mosque congregation consents and no one objects.