The phrase: "and a person will get the reward according to his
intention": Ibn Rajab said, "This statement tells us that our acts will
get us nothing but what we intended. If we have a good intention, we
will get a good reward and if we have a bad intention, we will get a bad
reward. In fact, this phrase is not a mere repetition of the first phrase.
To explain, the first phrase indicates that the validity or invalidity
of a given act depends on the intention that caused it to come into
existence. As for the second phrase, it indicates that a good reward for
a given act is conditional on a good intention and the punishment
for a given act is contingent on its bad intention. It may happen that
a certain act is intended to be just doing something that is lawful. In
such a case, such an act will incur neither reward nor punishment.
In other words, judging a given act to be good, bad, or permissible
depends on the intention that caused it to exist. However, an act
will be worthy of reward, punishment, or acceptability based on the
intention that makes it either good, bad, or permissible."