Solomon made an alliance with Pharaoh king of Egypt by marrying Pharaoh's daughter. Solomon brought her to the city of David until he finished building his palace, the Lord's temple, and the wall surrounding Jerusalem.
However, the people were sacrificing on the high places, because until that time a temple for the Lord's name had not been built.
Solomon loved the Lord by walking in the statutes of his father David, but he also sacrificed and burned incense on the high places.
The king went to Gibeon to sacrifice there because it was the most famous high place. He offered 1,000 burnt offerings on that altar.
At Gibeon the Lord appeared to Solomon in a dream at night. God said, "Ask. What should I give you?"
And Solomon replied, "You have shown great and faithful love to Your servant, my father David, because he walked before You in faithfulness, righteousness, and integrity. You have continued this great and faithful love for him by giving him a son to sit on his throne, as it is today.
"Lord my God, You have now made Your servant king in my father David's place. Yet I am just a youth with no experience in leadership.
Your servant is among Your people You have chosen, a people too numerous to be numbered or counted.
So give Your servant an obedient heart to judge Your people and to discern between good and evil. For who is able to judge this great people of Yours?"
Now it pleased the Lord that Solomon had requested this.
So God said to him, "Because you have requested this and did not ask for long life or riches for yourself, or the death of your enemies, but you asked discernment for yourself to understand justice,
I will therefore do what you have asked. I will give you a wise and understanding heart, so that there has never been anyone like you before and never will be again.
In addition, I will give you what you did not ask for: both riches and honor, so that no man in any kingdom will be your equal during your entire life.
If you walk in My ways and keep My statutes and commandments just as your father David did, I will give you a long life."
Then Solomon woke up and realized it had been a dream. He went to Jerusalem, stood before the ark of the Lord's covenant, and offered burnt offerings and fellowship offerings. Then he held a feast for all his servants.
Then two women who were prostitutes came to the king and stood before him.
One woman said, "Please my lord, this woman and I live in the same house, and I had a baby while she was in the house.
On the third day after I gave birth, she also had a baby and we were alone. No one else was with us in the house; just the two of us were there.
During the night this woman's son died because she lay on him.
She got up in the middle of the night and took my son from my side while your servant was asleep. She laid him at her breast, and she put her dead son in my arms.
When I got up in the morning to nurse my son, I discovered he was dead. That morning, when I looked closely at him I realized that he was not the son I gave birth to."
"No," the other woman said. "My son is the living one; your son is the dead one." The first woman said, "No, your son is the dead one; my son is the living one." So they argued before the king.
The king replied, "This woman says, 'This is my son who is alive, and your son is dead,' but that woman says, 'No, your son is dead, and my son is alive.' "
The king continued, "Bring me a sword." So they brought the sword to the king.
Solomon said, "Cut the living boy in two and give half to one and half to the other."
The woman whose son was alive spoke to the king because she felt great compassion for her son. "My lord, give her the living baby," she said, "but please don't have him killed!" But the other one said, "He will not be mine or yours. Cut [him in two]!"
The king responded, "Give the living baby to the first woman, and don't kill him. She is his mother."
All Israel heard about the judgment the king had given, and they stood in awe of the king because they saw that God's wisdom was in him to carry out justice.