According to a Hadith from Sahih al-Bukhari, Tarawih prayer is eight rakats. The Prophet (pbuh) led the Taraweeh Prayer for eight rakats. The Taraweeh Prayer is a sunnah al-muakkada. The shortest is two rakats and the longest is twenty rakats. However, during the time of Umar b. Abdulaziz, the people of Medina observed the Taraweeh Prayer for thirty-six rakats. (Fathu’l Bari, v.4, p.220)
The number of rakats of the Taraweeh Prayer is based on the practice of Umar (may Allah be pleased with him). Umar led the Taraweeh Prayer in Masjid an-Nabawi for twenty rakats in the final times of his caliphate. After the period of Four Caliphs, no one objected to observing the Taraweeh prayer for twenty rakats. Scholars depend acted upon this hadith of the Prophet (pbuh) regarding this issue:
“ After me, follow my sunnah and the sunnah of the caliphs in the right path” (Tirmidhi, Ilm, 16; Ibn Hanbal, IV, 126).
Furthermore, it is reported that Abdullah b. Abbas (may Allah be pleased with him) observed the Taraweeh Prayer for twenty rakats and afterwards he observed three rakats of Witr prayer in the month of Ramadan. When Imam Abu Hanifa was asked about Umar’s application as regards to this issue, he answered:
Taraweeh Prayer is a sunnah al-muakkada with no doubt. Umar’s observing this prayer in community and for twenty rakats is not a personal preference and not an innovation, either. He did so depending on a juridical principle that he knew and on a will of Muhammad (pbuh). (at-Tahtawi, Hashiya, 334).
Performing it twenty-rakat is the better one. In the present time, some people insist that tarawih prayer is eight rakats basing their claim on a hadith reported by Hazrat Aisha. Nevertheless, Ibn Abbas (may Allah be pleased with him) related that our Prophet performed twenty rakats of tarawih prayer and witr prayer (a necessary prayer performed between night prayer and dawn prayer) in congregation during the month of Ramadan. Moreover, concerning the issue, the companions of our prophet had unity of action. After all, the tarawih prayer is twenty rakats according to the Hanafi, Shafi'i and Hanbali, madhhabs (schools of law). In the Maliki school, there are two opinions about it: one is twenty rakats and the other is thirty-six rakats. However, the twenty-rakat view is more common. For this reason, the ones who are too old and sick should at least perform eight rakats if they can afford it, and yet Muslim people who are robust enough must perform the twenty-rakat prayer.