Solomon arranged a marriage contract with Pharaoh, king of Egypt. He married Pharaoh's daughter and brought her to the City of David until he had completed building his royal palace and God's Temple and the wall around Jerusalem.
Meanwhile, the people were worshiping at local shrines because at that time no temple had yet been built to the Name of God.
Solomon loved God and continued to live in the God-honoring ways of David his father, except that he also worshiped at the local shrines, offering sacrifices and burning incense.
The king went to Gibeon, the most prestigious of the local shrines, to worship. He sacrificed a thousand Whole-Burnt-Offerings on that altar.
That night, there in Gibeon, God appeared to Solomon in a dream: God said, "What can I give you? Ask."
Solomon said, "You were extravagantly generous in love with David my father, and he lived faithfully in your presence, his relationships were just and his heart right. And you have persisted in this great and generous love by giving him - and this very day! - a son to sit on his throne.
"And now here I am: God, my God, you have made me, your servant, ruler of the kingdom in place of David my father. I'm too young for this, a mere child! I don't know the ropes, hardly know the 'ins' and 'outs' of this job.
And here I am, set down in the middle of the people you've chosen, a great people - far too many to ever count.
"Here's what I want: Give me a God-listening heart so I can lead your people well, discerning the difference between good and evil. For who on their own is capable of leading your glorious people?"
God, the Master, was delighted with Solomon's response.
And God said to him, "Because you have asked for this and haven't grasped after a long life, or riches, or the doom of your enemies, but you have asked for the ability to lead and govern well,
I'll give you what you've asked for - I'm giving you a wise and mature heart. There's never been one like you before; and there'll be no one after.
As a bonus, I'm giving you both the wealth and glory you didn't ask for - there's not a king anywhere who will come up to your mark.
And if you stay on course, keeping your eye on the life-map and the God-signs as your father David did, I'll also give you a long life."
Solomon woke up - what a dream! He returned to Jerusalem, took his place before the Chest of the Covenant of God, and worshiped by sacrificing Whole-Burnt-Offerings and Peace-Offerings. Then he laid out a banquet for everyone in his service.
The very next thing, two prostitutes showed up before the king.
The one woman said, "My master, this woman and I live in the same house. While we were living together, I had a baby.
Three days after I gave birth, this woman also had a baby. We were alone - there wasn't anyone else in the house except for the two of us.
The infant son of this woman died one night when she rolled over on him in her sleep.
She got up in the middle of the night and took my son - I was sound asleep, mind you! - and put him at her breast and put her dead son at my breast.
When I got up in the morning to nurse my son, here was this dead baby! But when I looked at him in the morning light, I saw immediately that he wasn't my baby."
"Not so!" said the other woman. "The living one's mine; the dead one's yours." The first woman countered, "No! Your son's the dead one; mine's the living one." They went back and forth this way in front of the king.
The king said, "What are we to do? This woman says, 'The living son is mine and the dead one is yours,' and this woman says, 'No, the dead one's yours and the living one's mine.'"
After a moment the king said, "Bring me a sword." They brought the sword to the king.
Then he said, "Cut the living baby in two - give half to one and half to the other."
The real mother of the living baby was overcome with emotion for her son and said, "Oh no, master! Give her the whole baby alive; don't kill him!" But the other one said, "If I can't have him, you can't have him - cut away!"
The king gave his decision: "Give the living baby to the first woman. Nobody is going to kill this baby. She is the real mother."
The word got around - everyone in Israel heard of the king's judgment. They were all in awe of the king, realizing that it was God's wisdom that enabled him to judge truly.