Notice that this occurred when he was old and his heart had almost stopped following the Lord. He did go after the Lord, but he did it in a haphazard way. Solomon is perhaps the most vivid example of a Laodicean in the entirety of the Bible (Revelation 3:14-22).
His downfall began with laxity toward being careful about keeping God's commands regarding idolatry. Laxity is the first stage of lawlessness. The more lax he became, the more double-minded he became. A double minded person loses his grip. It is like trying to grasp two different objects in one's hands. If one is not really sure which he wants to hang onto, and his mind is playing back and forth between them, his grip will loosen on one or the other, because he will want to let go of the one in order to secure the other, if he feels he has a better chance with the other.
In Solomon's case, it is his mental, spiritual grip that is suspect. He gradually came to the place where he was not really hanging onto anything but straddling between choices. This made him become increasingly unstable, unsettled, and even deceitful until he became completely reintegrated into the world. He began to be moved almost entirely by human nature once again.
Why is the first commandment listed first? It is the most important of all the commandments. God wants to draw special attention to it because it is the one that is also most easily broken.
John W. Ritenbaugh
Deception, Idolatry and the Feast of Tabernacles
God was not well pleased with Solomon. Influenced by his many foreign wives and concubines, Solomon became enmeshed in pagan worship. Failing to heed God's warning of the "snare" which foreign wives would become (Exodus 34:11-16), he allowed his wives to turn him to false gods. I Kings 11:4 sums up the matter of his turpitude: Solomon's "heart was not loyal to the LORD his God, as was the heart of his father David."
Searching for Israel (Part Five): Solomon and the Divided Kingdom
Other Forerunner Commentary entries containing 1 Kings 11:6:
1 Kings 3:5-10
1 Kings 11:42
2 Chronicles 9:22-28