And Solomon made affinity with Pharaoh king of Egypt, and took Pharaoh’s daughter, and brought her into the city of David, until he had made an end of building his own house, and the house of the LORD, and the wall of Jerusalem round about. Only the people sacrificed in high places, because there was no house built unto the name of the LORD, until those days. And Solomon loved the LORD, walking in the statutes of David his father: only he sacrificed and burnt incense in high places. And the king went to Gibeon to sacrifice there; for that was the great high place: a thousand burnt offerings did Solomon offer upon that altar.
In Gibeon the LORD appeared to Solomon in a dream by night: and God said, “Ask what I shall give thee.”
And Solomon said, “Thou hast shewed unto Thy servant David my father great mercy, according as he walked before Thee in truth, and in righteousness, and in uprightness of heart with Thee; and Thou hast kept for him this great kindness, that Thou hast given him a son to sit on his throne, as it is this day. And now, O LORD my God, Thou hast made Thy servant king instead of David my father: and I am but a little child: I know not how to go out or come in. And Thy servant is in the midst of Thy people which Thou hast chosen, a great people, that cannot be numbered nor counted for multitude. Give therefore Thy servant an understanding heart to judge Thy people, that I may discern between good and bad: for who is able to judge this Thy so great a people?”
And the speech pleased the Lord, that Solomon had asked this thing. And God said unto him, “Because thou hast asked this thing, and hast not asked for thyself long life; neither hast asked riches for thyself, nor hast asked the life of thine enemies; but hast asked for thyself understanding to discern judgment; Behold, I have done according to thy words: lo, I have given thee a wise and an understanding heart; so that there was none like thee before thee, neither after thee shall any arise like unto thee. And I have also given thee that which thou hast not asked, both riches, and honour: so that there shall not be any among the kings like unto thee all thy days. And if thou wilt walk in My ways, to keep My statutes and My commandments, as thy father David did walk, then I will lengthen thy days.”
And Solomon awoke; and, behold, it was a dream. And he came to Jerusalem, and stood before the ark of the covenant of the LORD, and offered up burnt offerings, and offered peace offerings, and made a feast to all his servants. 1 Kings 3:1-15
References: 1 Kings 1; 2; 3; Proverbs 3:2; Matthew 7:7-8; Mark 10:36; John 14:13-14; 15:16; James 1:5-6; 1 John 5:14-16