In al-Saheehayn (the following version was narrated by al-Bukhaari) it is narrated from Abu Hurayrah that the Messenger of Allaah (peace and blessings of Allaah be upon him) said:
“By the One in Whose hand is my soul, I had thought of ordering that wood be gathered, then I would command the call to prayer to be given, and I would appoint a man to lead the people in prayer, then I would go to men [who do not attend the congregational prayer] and burn their houses down around them. By the One in Whose hand is my soul, if anyone of you had known that he would receive a bone covered with meat or two (small) pieces of meat in a sheep’s foot, he would come for ‘Isha’ prayerAl-Bukhaari.” 7224; Muslim, 651.
Ibn al-Mundhir (may Allaah have mercy on him) said: The fact that he was thinking of burning down the houses of people who did not attend the prayer is the clearest evidence that attending prayer in congregation is obligatory, because it would not be permissible for the Prophet (peace and blessings of Allaah be upon him) to do this with regard to something that was mustahabb and not obligatory. Al-Awsat, 4/13
And it was narrated that the Prophet (peace and blessings of Allaah be upon him) said: “Whoever hears the call to prayer and does not come, there is no prayer for him [i.e., his prayer is not valid], unless he has an excuse.” Narrated by Ibn Maajah, al-Daaraqutni, Ibn Hibbaan and al-Haakim with a saheeh isnaad. It was said to Ibn ‘Abbaas, what is an excuse? He said, Fear or sickness.