One of the sages argued that King Solomon did not sin, and that any who thinks he did is in error. How did he know that Solomon did not sin? It is written, “For it came to pass, when Solomon was old, that his wives turned away his heart after other gods, and his heart was not perfect with the Lord his G-d as was the heart of David his father” (I Kings 11:4). From the comparison between Solomon and the righteous David we learn, the sage argued, that though Solomon’s heart was not perfect as was his righteous father’s, he was also not a sinner. If so, that same sage asked, how do we interpret the start of the verse, “For it came to pass, when Solomon was old, that his wives turned away his heart after other gods”?
Answer: True, the wives did try to sway Solomon’s heart towards idolatry, but he did not succumb. The scholars asked: Do not the Scriptures immediately follow with “For Solomon went after Ashtoreth the goddess of the Zidonians…And Solomon did evil in the sight of the Lord…Then did Solomon build an high place [an altar for idolatry]… And likewise did he for all his strange wives, which burnt incense and sacrificed unto their gods” (I Kings 11:5-8). This means that Solomon actually did build houses for idolatry. Answer: The Hebrew literally reads “Then will Solomon build,” meaning that he had planned to build them, but did not actually do so. The scholars asked: If that is the case, if the words mean that he planned to build but did not actually build, how do we interpret what is written about Joshua, “Then will Joshua build an altar unto the Lord, G-d of Israel” (Joshua 8:30)? Does this mean he meant to build an altar but did not? It is inconceivable that such a righteous man as Joshua would plan to build an altar to G-d yet not actually build it. So we return to our starting point: how do we know that Solomon did not sin? The above sage argued that there is proof from the Scriptures that Solomon did not sin; from the story of King Josiah we learn of King Solomon. It is said of King Josiah that he smashed and broke the statues, idols, and high places which Solomon made. It is written “[And King Josiah smashed and broke] the high places…which Solomon the king of Israel had built for Ashtoreth the abomination of the Zidonians, and for Chemosh the abomination of the Moabites…and he broke the images, and cut down the groves.” How is it possible, the sage asked, that up until the time of King Josiah there were still statues and idols? Weren’t they smashed by the righteous kings who preceded him, King Asa and King Jehosaphat? It is written, “And Asa did [that which was] right in the eyes of the LORD…and he removed all the idols that his fathers had made” (I Kings 15 11-12).
You are forced to interpret this, the sage argued, to mean that Josiah did not actually smash the idols, yet he was praised by the Scriptures, and so in the case of King Solomon. Though he did not actually worship idols he was denounced by the Scriptures as though he had sinned. The scholars went on to ask: The Scriptures explicitly state that Solomon sinned, for it is written “And Solomon did evil in the sight of the Lord.” Answer: Solomon did not actually sin, yet the Scriptures treat him as though he did because he did not protest or reprove his wives. Since Solomon saw his wives sinning and did not stop them, the Scriptures treat him as though he, himself, sinned.
(Babylonian Talmud, Tractate Shabbat 56b)