The narration reported from the Prophet (peace and blessings be upon him and his family): "Indeed, actions are judged by intentions, and for every person is that which they intended."
Ali Akbar al-Ghaffari
Tahdhīb al-Aḥkām fī Sharḥ al-Muqniʿah, vol. 1, p. 86