Praise be to Allaah.
Allaah says (interpretation of the meaning):
“And nothing prevents their contributions from being accepted from them except that they disbelieved in Allaah and in His Messenger (Muhammad)”
[al-Tawbah 9:54]“If you join others in worship with Allaah, (then) surely, (all) your deeds will be in vain, and you will certainly be among the losers”
Shaykh Ibn ‘Uthaymeen said, when listing the conditions of prayer being valid:
There are other conditions which include: being Muslim, being of sound mind, and having reached the age of discretion… No act of worship is valid unless one is a Muslim, of sound mind and has reached the age of discretion, apart from zakaah, which is obligatory upon the insane and minors, according to the correct opinion. With regard to the validity of Hajj performed by a minor, there are texts which state that it is valid.
Al-Sharh al-Mumti’, 2/95, Ibn al-Jawzi edition.
And he said:
The conditions of prayer are: being Muslim, being of sound mind, and having reached the age of discretion; that the time for prayer has begin; covering the ‘awrah; having purified oneself from anything that invalidates wudoo’; avoiding najaasah (impurity); facing the qiblah; and having the intention of praying.
Al-Sharh al-Mumti’, 2/289, Ibn al-Jawzi edition.
The same applies to the other acts of worship; they can only be accepted from a Muslim, so Islam or being a Muslim is a condition of acts of worship being valid, and their being accepted depends on that.