In the Name of Allah, Most Gracious, Most Merciful.
All praise and thanks are due to Allah, and peace and blessings be upon His Messenger.
Dear questioner! Thank you for this question, which reflects a true desire to learn more about Islam and its guidance that lead to happiness and peace of mind.
It goes without saying that Prayer is the pillar of Islam, the pinnacle of good deeds, and the peak of obedience. `Uthman ibn `Affan (may Allah be pleased with him) reported that the Prophet (peace and blessings be upon him) said: "If the time for a prescribed Salah comes, and a Muslim performs wudu' (ablution) properly (and then offers his Salah) with humility and bowing (to Allah), it will be an expiation for his past sins, so long as he has not committed a major sin; and this is applicable to all times." (Reported by Muslim.)
Coming to the question in point, here is the fatwa issued by Al-Azhar House of Fatwa in this regard:
It is unanimously agreed upon among scholars that Salah is obligatory upon Muslims and that Muslim parents are to order their children when they are seven years old to perform it, but if the children have reached ten years old without observing Salah, their parents are to beat them for that. Beating in that case is to be with the hand, not a harmful instrument. There is a Hadith to that effect: "Order your children to perform Salah when they are seven years old, and beat them (if they have neglected it) when reaching ten years old. And separate between your male and female children in bed."
The one who denies that Salah is obligatory is regarded as an unbeliever, for the Salah is one of the pillars of Islam, and the evidence for this is clear cut. There is a scholarly consensus upon that.
As for the one who holds that the Salah is obligatory, but he abandons it out of lack of concern (as it is the case of many Muslim people), there is a scholarly difference as to judging him.
According to the majority of the righteous Muslim predecessors and the majority of the righteous successors, including Imams Malik and Ash-Shafi`i, he who does so is not to be regarded as an unbeliever; rather, he is to be regarded as a sinner. Accordingly, if he repents, he will save himself from severe punishment, and if he does not, he will be executed for committing a sin punishable by death, as it is the case with a married person who commits adultery. According to those scholars, executing the person who abandons Salah in that case is to be by cutting his head off with a sword.
Another group of the righteous predecessors believed that the one who abandons Salah while still believing it to be obligatory is to be considered an unbeliever. Such an opinion was attributed to `Ali ibn Abi Talib (may Allah honor him). Such point of view was also reported to have been said by Imam Ahmad ibn Hanbal. (Yet there was another opinion in that regard also reported to have been said by Imam Ahmad.) Some of the followers of Imam Ash-Shafi`i held that opinion, too.
Imam Abu Hanifah, a group of the Kufic scholars, and Al-Mazni, a follower of Imam Ash-Shafi`i, were of the opinion that the one who holds that Salah is obligatory yet neglects observing it is not to be considered an unbeliever, nor is he to be executed. Rather, he is to be punished with a punishment that the judge sees appropriate to his case, and he is to be imprisoned until he performs Salah. It was also said that he is to be beaten until he agrees to perform Salah, or he is to be beaten until he bleeds and agrees to pray.
Each of the above opinions cited evidence to support its point of view. Some of these pieces of evidence are quotations from the Qur'an and some are Hadiths of Prophet Muhammad (peace and blessings be upon him).
As for our point of view in that regard, we recommend adopting the opinion of Imam Abu Hanifah, that is, that the one who abandons Salah out of lack of concern yet still holds that it is obligatory is not to be regarded as an unbeliever, nor is he to be executed for insisting to neglect it; rather, he is to be imprisoned and punished until he performs Salah. We recommend that opinion, for it is not a severe one.
As to the suggestion that the Muslim governments are to oblige the people to perform Salah, it is up to the rulers in authority to decide what to do in that concern according to the general benefit of the people."
Salah: Virtue & Significance