However , good motivation behind a wrong action does not make it good.and does not justify it. In other words , the good intention is not a valid excuse for commiting wrongful or sinful acts. However ,if the person does this out of ignorance he might be exempted.
In islam , Niyyah ( intention ) is part of every act of worship.
The validity of the act of worship depends upon the sincerity of intention.
1. If the intention is sencerity for the sake of Allah , the act of worship is correct and accepted.
The Propheta (peace be upon him) said; ” On the Day of resurrection deeds will be presented to Allah .From them the deeds done sincerely for Allah’s sake will be separated and the rest will be thrown in the Fire of Hell.”
2. If the intention is not for the sake of Allah then the act of worship is incorrect and rejected.
3. If the intention backing the act of worship is to please Allah but mixed with other purposes then the act of worship is incorrect and will be rejected for Allah Almighty ;
The Prophet (peace be upon him)said: Whosoever prays to show off is associating a partner with Allah .Whosoever fasts to show off , he is associating a partner with Allah.Whosoever gives a charity to show off he is associating a partner with Allah “.
The Hadith emphasizes that the muslim must be sincere , truthful , and honest in his act of worship , he must make them all exclusively for the sake of Allah alone.
Sincerity is one of the conditions od accepting good deeds.
The other condition is that the action must be done in accordance with the Shariah as it will be explained in the other Hadith.