During the time of Prophet Musa, there was a pious man, who used to pray day and night on the roof of his house. One day some people came and told him that there was a garden where a tree was being worshipped by a group of people. Hearing the pious man picked up an axe and went to that tree with the intention of cutting and uprooting it altogether.
Satan (the Devil) came to him in the form of an old man and asked:" What are you aiming to do? " The pious man explained what was happening and his intention to cut the tree. Satan said: “What have you to do with it? If God wished the tree to be cut, he would have sent his Prophet to do it”.
The pious man did not listen. The two went on arguing and quarrelling till they came to blows. He managed to knock the Satan down on the floor and sat on him, aiming at cutting his throat. The Satan begged him for pardon and release saying, "Let me suggest you one thing which would help you in this world as well as in the next world. I shall pay you two dinars everyday. You can pay partly to the poor and partly spend for your own self. Leave this tree uncut till God commanded whether it was right or wrong to cut it.”
The pious man was misled by the Satan. He thought the suggestion was right and returned home. On the second day, he saw two dinars under his pillow. He was delighted with the money and spent some after the poor.
But on the following day, he did not see the money again as expected,so he again took his axe and went to the tree. Again Satan came to him in the form of an old man and asked him, "What do you want to do?" He said, "I want to cut that tree." Satan told him that he had no power to do it so it was better he went back home. He did not agree and again they fought. This time the Satan succeeded in overpowering the pious man and knocked him down on the floor.
The pious man was surprised at this and asked Satan why it so happened that he could not overpower him this time. The Satan replied: "Whoever does a good deed purely for the pleasure of God, no one can face him but if he does it with an aim of worldly gain, then he loses strength and stands to fail."
Why did the pious man win on the first day and lose on the second in his fight against the Satan? Because his first intention to cut the tree, was to please God and nothing else. But the second day, his good intention had changed and it had become for the sake of money. So the God given spiritual strength which he had on the first day had then disappeared and so he lost.