For three long years Solomon journeyed about, begging his way from city to city, and from country to country, atoning for the three sins of his life by which he had set aside the commandment laid upon kings in Deuteronomy not to multiply horses, and wives, and silver and gold. At the end of that time, God took mercy upon him for the sake of his father David, and for the sake of the pious princess Naamah, the daughter of the Ammonite king, destined by God to be the ancestress of the Messiah.
The time was approaching when she was to become the wife of Solomon and reign as queen in Jerusalem. God therefore led the royal wanderer to the capital city of Ammon. Solomon took service as an underling with the cook in the royal household, and he proved himself so proficient in the culinary art that the king of Ammon raised him to the post of chief cook. Thus he came under the notice of the king's daughter Naamah, who fell in love with her father's cook.
In vain her parents endeavored to persuade her to choose a husband befitting her rank. Not even the king's threat to have her and her beloved executed availed to turn her thoughts away from Solomon. The Ammonite king had the lovers taken to a barren desert, in the hope that they would die of starvation there. Solomon and his wife wandered through the desert until they came to a city situated by the sea-shore.
They purchased a fish to stave off death. When Naamah prepared the fish, she found in its belly the magic ring belonging to her husband, which he had given to Asmodeus, and which, thrown into the sea by the demon, had been swallowed by a fish. Solomon recognized his ring, put it on his finger, and in the twinkling of an eye he transported himself to Jerusalem. Asmodeus, who had been posing as King Solomon during the three years, he drove out, and himself ascended the throne again.