The following story from the Talmud (Menachos 44a) is about a Torah scholar whose tzitzit save him from sin.
Once there was a man who was always careful to keep the mitzvah of tzitzit properly. When he happened to hear about a prostitute in a faraway place overseas who charged 400 zehuvim, he sent that sum and arranged a date. When the set time arrived he came and sat at her doorway. The prostitute’s assistant went inside and told her mistress, who then told the assistant to show him in.
The prostitute prepared seven beds of silver and one of gold. There were silver ladders connecting them, and a gold ladder leading to the uppermost bed.
She went up to the top bed and sat there naked. He, too, climbed up to the top bed and sat there naked opposite her. Suddenly his four tzitzits smacked him on the face. He went down and sat on the floor.
She said she would not leave him alone until he revealed what blemish he had seen in her. “Never have I seen a woman as beautiful as you,” he replied, “but Hashem our God commanded us to do a certain mitzvah known as tzitzit. The verse related to it says, ‘I am Hashem your God’ twice, teaching us that He exacts retribution and pays just wages. My tzitzit were like four witnesses against me. ”
“I won’t let you go,” she said, “until you tell me your name, the name of your city, the name of your rabbi and the name of the beit midrash where you study.” He wrote all the information down on a piece of paper and handed it to her. They parted.
She then divided all her assets: one-third for the government [as a payoff so they would permit her to convert], one-third for the poor and one-third she took with her. Arriving at the beit midrash of R’ Chiya, she asked him to convert her to Judaism.
“My daughter,” he said. “perhaps you have cast your eyes upon [i.e. taken a liking] one of the students?”
She handed him the piece of paper, recounting the entire story behind it. “Go collect your due,” he said to her.
And those same sheets she had laid to commit a transgression were used for a mitzvah instead. This is an instance of how sometimes one receives reward both in This World and the World to come.