Assalamualaikum w.b.t. What is the ruling if a person invalidates his sunnah prayer when the iqama is called? The reason is I once went to the mosque and perform the tahiyatul masjid prayer, but suddenly when I was still praying the iqama was called. Should I complete my prayer or invalidate the sunnah prayer I was performing and follow the obligatory congregational prayer?
Alhamdulillah, praise and gratitude to Allah SWT for His countless blessings for us all. Praise and salutations to our beloved Prophet Muhammad PBUH, his family, companions and all those who follow his footsteps until the Last Day.
Sunnah prayer is among the worships commanded by syara’ to be performed. Sunnah prayers that are encouraged are promised their own rewards. Among them is its advantage of being able to increase or accommodate the flaws in the obligatory prayer of a person. In a hadith from Abu Hurairah RA, the Prophet PBUH said:
إِنَّ أَوَّلَ مَا يُحَاسَبُ بِهِ الْعَبْدُ يَوْمَ الْقِيَامَةِ مِنْ عَمَلِهِ صَلاَتُهُ، فَإِنْ صَلَحَتْ فَقَدْ أَفْلَحَ وَأَنْجَحَ، وَإِنْ فَسَدَتْ فَقَدْ خَـابَ وَخَسِرَ، فَإِنِ انْتَقَصَ مِنْ فَرِيْضَةٍ شَيْئًا، قَـالَ الرَّبُّ تَبَـارَكَ وَتَعَالَى: اُنْظُرُوْا هَلْ لِعَبْدِي مِنْ تَطَوُّعٍ، فَيُكَمَّلُ بِهِ مَا انْتَقَصَ مِنَ الْفَرِيْضَةِ ثُمَّ يَكُوْنُ سَائِرُ عَمَلِهِ عَلَى نَحْوِ ذَلِكَ.
“The first of his deeds for which a man will be taken into account on the day of resurrection will be his prayer. If it is sound, he will be saved and successful, but if it is unsound, he will be unfortunate and miserable. If any deficiency is found in his obligatory prayer the Lord who is blessed and exalted will issue instructions to consider whether His servant has said any voluntary prayers so that what is lacking in the obligatory prayer may be made up by it. Then the rest of his actions will be treated in the same fashion.” 
The author of al-Fiqh al-Manhaji (1/509-528) when explaining sunnah or nafal prayers stated: The word nafal (النَّفَلُ) lexically means additional. Whereas the terminology means a prayer other than the obligatory prayer. It is named as such because it is an additional prayer to the obligatory prayer. This prayer is also called sunnah, mandub or mustahab.
Sunnah prayers are divided into two types. The first is the type that isn’t sunnah to be performed in congregation and another type is sunnah to be performed in congregation.
Regarding sunnah prayers that aren’t sunnah to be performed in congregation, it can be further divided into two, sunnah prayers that accompany the obligatory prayers and sunnah prayers that don’t accompany obligatory prayers.
First: Sunnah prayers that accompany obligatory prayers.
Sunnah prayers that accompany obligatory prayers are divided into two, which are the muakkad and non-muakkad sunnah prayers. Muakkad sunnah prayers are the two rakaat prayer before the Subuh prayer, two rakaat before and after the Zuhur prayer, two rakaat after the Maghrib prayer and two rakaat after Isya’ prayer. The most muakkad among all of these sunnah prayers is the two rakaat before the Fajar prayer. 
Second: Prayers that do not accompany the obligatory prayers.
This sunnah prayer is also divided into two, the sunnah prayer which has a specific name and time to be performed, and Mutlaq sunnah prayer where its name and time aren’t specified.
The sunnah prayers that have specific names and times to be performed are as the following:
- Tahiyyatul Masjid prayer
- Witir prayer
- Dhuha prayer
- Istikharah prayer
While regarding Mutlaq sunnah prayer that hasn’t been specified in its name and time, it can be performed as many times as one wishes and at any time that is not makruh to pray. This is based on a hadith of Prophet PBUH where the Prophet PBUH said to Abu Dzar RA:
الصَّلاَةُ خَيْرُ مَوْضُوْعٍ اسْتَكْثِرْ أَوْ أَقِلَّ
“Prayer is the best of worship. Thus, perform as many or least as you wish.” 
All sunnah prayers mentioned above are not sunnah to be performed in congregation. The sunnah prayers that are sunnah to be performed in congregation are the two sunnah Eid prayers, Tarawih prayer, the sunnah moon and solar eclipse prayers as well as the sunnah prayer asking for rain (Istisqa’). 
Invalidating a Sunnah Prayer When the Iqamah is Called
In answering the above question, we first present several situations that may happen according to the above question asked:
When one is praying and the iqamah is called. What should be done?
First situation: If one enters a mosque and the iqamah is already called to perform the obligatory prayer, then it is makruh for any sunnah prayer to be performed and one should immediately prepare to perform the obligatory prayer in congregation. This follows a hadith from Abu Hurairah RA where Rasullullah PBUH said:
إِذَا أُقِيمَتِ الصَّلاَةُ فَلاَ صَلاَةَ إِلاَّ الْمَكْتُوبَةُ
“When the time for prayer comes, only the prescribed prayer is to be said.” 
This is as mentioned by al-Imam al-Nawawi in the chapter explaining the hadith saying: “It is makruh to try and get the nafilah (by performing a prayer) after the iqamah is called such as the sunnah prayer (ratib) of Subuh, Zuhur and others, whether or not one knows whether he can get the rakaat with the imam or otherwise.” 
Second situation: If when one is praying a sunnah prayer and the iqamah is being called out, then it is sunnah to complete the sunnah prayer if there is no concern that he might miss the congregational prayer with the imam giving the salam. 
This is in accordance with the statement of Allah SWT:
يَٰٓأَيُّهَا ٱلَّذِينَ ءَامَنُوٓاْ أَطِيعُواْ ٱللَّهَ وَأَطِيعُواْ ٱلرَّسُولَ وَلَا تُبۡطِلُوٓاْ أَعۡمَٰلَكُمۡ
“O you who have believed, obey Allah and obey the Messenger and do not invalidate your deeds.” 
It is encouraged to lighten (simplify it but fulfilling all the requisites of prayer) the sunnah prayer and hasten to get the rewards of the congregational prayer and it is prioritized to get the takbiratul ihram together with the imam.
Third situation: If there is fear that one might miss the congregational prayer, then it is sunnah to stop the sunnah prayer by immediately giving salam. As for Friday prayer, if there is fear that one might miss the congregational Friday prayer, then in this situation it is wajib (obligatory) to stop the sunnah prayer. 
Fourth situation: If one is praying a sunnah prayer, then the iqamah is being called for the obligatory congregational prayer and he is certain that if he continues with his prayer then he will miss the congregational prayer, however, there is also strong certainty that there will be new congregants coming to perform the congregational prayer, then in such a situation, it is best to complete the sunnah prayer.
If a person is performing the obligatory prayer alone, then other congregants arrive to perform the obligatory prayer in congregation, what should be done?
- If there is a new group of congregants for obligatory prayer and a person is praying alone at the time, whether it is the Subuh prayer or 3 rakaat prayer (Maghrib) or 4 rakaat prayer (Zuhur and Asar), if he has completed the first 2 rakaat or in the third rakaat, then complete the prayer and then join the obligatory congregational prayer at the time. 
- If the person praying is in the first or second rakaat (has yet to perform the third rakaat), then it is sunnah to change the intention into sunnah prayer, simplify it into two rakaat and then join the congregation obligatory prayer at the time. 
- If one decides not to stop his obligatory prayer alone and doesn’t want to change the intention to sunnah prayer and just continue praying alone, then it is makruh. It is valid if he joins the congregation where it made it so that he is praying alone at first then ends his prayer in congregation.
For example: Umar is performing the Zohor prayer alone at the mosque and when he is in his third rakaat (while he is reciting the Fatihah, for instance, or other recitations) then a group of congregants come in to perform the Zohor prayer in congregation. The congregants begin praying and Umar immediately joins the congregation and continues his prayer. When the congregation is in the first tahiyyat, Umar is already in his final tahiyyat because originally Umar has prayed alone for the first two rakaat and then join the congregation. In this situation, Umar can choose to set the intention of mufarraqah (separate himself from the congregation) and gives the salam or just stay in the position and wait to give the salam together with the imam.
As explained above, if a person is performing sunnah qabliyyah prayer and hears the iqamah is called, then he can invalidate his prayer if he fears that he might miss the fadhila of the congregational prayer.
While if there is a strong assumption that he has time to complete his prayer and not miss the fadhila of congregational prayer, that is performing the takbir together with the imam, hence, it is prioritized for him to first complete his sunnah prayer.
May Allah SWT include us as those who are successful in always maintaining the prayer and its rights. Amin.
 Narrated by al-Nasa’ie (451), (452) and al-Tirmizi (411)
 Regarding this division, we have previously explained it in Ahkam Syari’yyah titled: #78: The Muakkad and Non-Muakkad Rawatib Prayers. (https://maktabahalbakri.com/78-2/)
 Narrated by Ibn Majah (901)
 See al-Fiqh al-Manhaji, 1/509-528
 Narrated by Muslim (710)
 See al-Minhaj Syarh Sahih Muslim, 5/221
 See Mughni al-Muhtaj, 1/500
 Surah Muhammad: 33
 See Mughni al-Muhtaj, 1/500
 See Mughni al-Muhtaj, 1/500