The number of Raka'at in Taraweeh is 20 and it is Sunnah Moukkada (Compulsory Sunnah) for both men and women. For men offering it in the Masjid along with the congregation (Jama'at) is Fardh Kifayah. If all the men of a locality do not offer it, all of them will be considered sinners.
It is given in Durre Mukhtaar, Vol. 1, Pg No. 52:
Translation: Salaat Ul Taraweeh is by consensus Sunnah Moukkada, as the 4 rightly-guided Caliphs offered it regularly.
It is given in Raddul Muhtaar:
Translation: in Taraweeh, the Jama'at is Kifayah. If all the men of a locality leave the Jama'at, then all of them have abandoned the Sunnah and have done a very bad thing indeed.
As far as the number of the Raka'at of Taraweeh is considered that from the acts of the Holy Prophet (Sallallahu alaihi wa sallam) and the Traditions handed down by the Sahabah and by the sayings of the Tabi'een and the Tab'e Tabi'een, it is established beyond doubt that the number of Raka'at in Taraweeh is 20. This was the practice of the First 4 Caliphs and all the Sahabah agreed and consented to this.
There is a Hadith in Sunan Baihaqui, Imam Tabarani’s Mo’jam Kabeer, Mo’jam Ausat, Musannaf Ibn Abi Shaiba, Musnad Abd bin Humaid, Majma Uz Zawaaid and Zujajatul Masabeeh:
Translation: It has been narrated on the authority of Hadhrat Abdullah bin Umar (May Allah be well pleased with him) that the Holy Prophet (Sallallahu alaihi wa sallam) offered 20 raka’at of Taraweeh and Witr.
(Sunan Kubra Lil Baihaqui, Hadith No: 4799; Musannaf Ibn Abi Shaiba, Vol 2, Pg No: 286, Hadith No: 13; Al Matalib Ul A’aliya Li Ibn Hajar Asqalani, Hadith No: 642; Mo’jam Ausat Tabarani, Hadith No: 5598/810; Mo’jam Kabeer Tabarani, Hadith No: 11934; Majma Uz Zawaaid, Vol 2, Pg No: 172; Musnad Abd bin Humaid, Hadith No: 655; Zujajatul Masabeeh, Vol 1, Pg No: 366, Khulasatul Ahkaam Lin Nawawi, Vol 1, Pg No: 579, Hadith No: 1971; Al Talkhees Li Ibn Hajar Makki, Vol 2, Pg No: 52, Hadith No: 540; Fath Ul Bari Sharh Sahih Bukhari, Al Fiqha Tul Islami wa Adilla, Subul Ul Huda War Rashad, Vol 8, Pg No: 267)
Hadhrat Umar (May Allah be well pleased with him) gave the order for 20 Raka'at Taraweeh and this was the practice in the eras of Hadhrat Uthman and Hadhrat Ali (May Allah be well pleased with them).
There is a Hadith in Musannaf Ibn Abi Shaiba:
Translation: It has been narrated on the authority of Hadhrat Yahya bin Sae’ed that Hadhrat Umar (May Allah be well pleased with him) commanded a person to offer 20 raka’at of Taraweeh.
(Musannaf Ibn Abi Shaiba, Vol 2, Pg No: 285, Chapter No: 227, Hadith No: 3; Tuhfatul Ahwazi, Bab Ma Ja’a FI Shahri Ramadhan)
It has been narrated on the authority of Hadhrat Yazid bin Rooman R.A. that he said in the era of Hadhrat Umar Bin Khattab (May Allah be well pleased with him) people used to offer 23 raka’at (20 raka’at of Taraweeh and 3 Witr).
Translation: It has been narrated on the authority of Hadhrat Saib bin Yazid (May Allah be well pleased with him) that in the era of Hadhrat Umar (May Allah be well pleased with him) people used to offer 20 raka’at of Taraweeh. People used to recite 100 verses and in the era of Hadhrat Usman (May Allah be well pleased with him), they would support themselves with a staff because of the long raka’at.
Hadhrat Abu Abdur Rahman Sulami narrates on the authority of Hadhrat Ali (May Allah be well pleased with him), that in the month of Ramadhan, he (i.e. Hadhrat Ali) summoned the Huffaz (those who memorized the Holy Quran) and commanded one Hafidh of them to lead others for 20 raka’at of Taraweeh.
(Sunan Kubra Lil Baihaqui, Hadith No: 4804, Zujajatul Masabeeh, Vol 1, Pg No: 366, Umdatul Qari Sharh Sahih Bukhari, Kitab Ul Tahajjud, Tuhfatul Ahwazi, Bab Maa Jaa fi qiyami shahri Ramadhan)
20 Raka'at Taraweeh is the consensus of the Sahabah and all the Imams and the Fuqaha (Jurists) hold this opinion only.
Imam Kasani Hanafi (May Allah be well pleased with him) writes about 20 raka’at of Taraweeh:
Translation: The authentic opinion is of the majority of scholars, because Hadhrat Umar (May Allah be well pleased with him) gathered the Sahabah under the leadership (Imamat) of Hadhrat Ubai bin Kaab (May Allah be well pleased with him), and he lead them in 20 raka’at every night. None of the Sahabah denied this (or objected to this) and this way, the consensus of the Sahabah on this issue was achieved.
(Badai Us Sanai, Vol 1, Kitab Us Salaat, Pg No: 644)
Hadhrat Mulla Ali Qari (May Allah shower His Mercy on him) writes in his commentary on Mishkaat Sharh Mirqaat:
Translation: Nevertheless, the Sahabah have agreed that Taraweeh is of 20 raka’at.
(Mirqat Ul Mafateeh, Kitab Us Salaat, Bab Qiyami Shahri Ramadhan)
Allama Ibn e Nujaim (May Allah shower His Mercy on him) writes in Bahr Ur Raiq and Allama Ibn e Abidin Shami writes in Raddul Muhtaar:
Taraweeh is of 20 raka’at. The majority of the scholars agree on this and in east and west (i.e. everywhere), the Muslims practice this. (Al Bahr Ur Raiq, Vol 2, Pg No: 117)
(Radd Ul Muhtaar, Vol 1, Pg No: 521, Bidayatul Mujtahid, Vol 1, Pg No: 210, Al Fiqh Al Madhahib Al Arba, Vol 2, Pg No: 342)
It is given in Al Ghunya of Hadhrat Shaykh Abdul Qadir Jilani (May Allah be well pleased with him):
Translation: Salaat Ut Taraweeh is of 20 raka’at
(Al Ghunya Li Talibi tariqil haqqi, Vol 2, Pg No: 16)
There is a narration from Hadhrat Aisha Siddiqua (May Allah be well pleased with her) which mentions 8 raka’at.
Translation: It has been narrated on the authority of Hadhrat Abu Salma bin Abdur Rahman (May Allah be well pleased with him), he says that he asked Hadhrat Aisha Siddiqua (May Allah be well pleased with her) how was the Salaat of the Holy Prophet (Sallallahu alaihi wa sallam) in Ramadhan? Ummul Momineen Hadhrat Aisha (May Allah be well pleased with her) said: The Holy Prophet (Sallallahu alaihi wa sallam) would not offer more than 11 raka’at in Ramadhan and out of it. He would 4 raka’at with such fervor that you should not even talk about it. Then He (Sallallahu alaihi wa sallam) would 3 raka’at. I (i.e. Hadhrat Aisha) asked Him: O Prophet of Allah (Sallallahu alaihi wa sallam)! Do You rest before offering Witr? The Holy Prophet (Sallallahu alaihi wa sallam) said: O Aisha (May Allah be well pleased with her)! Verily My eyes sleep, my heart does not.
(Sahih Bukhari, Kitabul Tahajjud, Pg No: 154, Hadith No: 1147; Bab Fadhl min qiyami Ramadhan, Pg No: 269, Hadith No: 2013; Pg No: 504, Hadith No: 3569; Sahih Muslim Kitab Us Salaatil Musafireen, Hadith No: 738)
Saying on the basis of this Hadith that Taraweeh is only of 8 raka’at is a grave mistake, which is very much against the science of Hadith, the narration of Hadith and the understanding of Hadith.
When looked closely, it becomes obvious that this Hadith is not at all about Taraweeh, but about Tahajjud as Hadhrat Aisha (May Allah be well pleased with her) is talking about 8 raka’at in Ramadhan and out of it. Every sane person realizes that Taraweeh is offered only in Ramadhan and not out of it; otherwise, we should also say that Taraweeh is offered for the whole year. Even those who insist that Taraweeh do not offer it throughout the year! We can act upon this Hadith only when the 8 raka’at mentioned here are accepted in Tahajjud. That these 8 raka’at mean Tahajjud is also supported by this Hadith of Hadhrat Aisha (May Allah be well pleased with her), which comes in Sahih Bukhari:
Translation: It has been narrated on the authority of Hadhrat Aisha (May Allah be well pleased with her) that the Holy Prophet (Sallallahu alaihi wa sallam) would offer 11 raka’at, then when the day dawned, He (Sallallahu alaihi wa sallam) would offer 2 light raka’at. Then, He would rest on His right side to the point that the Muezzin would come and request Him.
(Sahih Bukhari, Vol 2, Kitab Ud Da’awat, Hadith No: 6310)
Thus, from all these we can safely say that Taraweeh is 20 Raka’at and this opinion has been the one that has been followed through the ages.
O Allah! Show us the Truth as Truth and help us to follow that; and show us falsehood as falsehood and help us to avoid that.