There are many parallels between Joseph, the hero of Parashat Miketz, and Solomon, the subject of its haftarah. Both serve in important governmental positions, Joseph as viceroy to Egypt’s Pharaoh, and Solomon as king of Israel. And both receive immense power–and immense wisdom–through dreams.
The haftarah opens with the words "It was all a dream!" This line refers to the scene which immediately precedes it, in which God offers to grant any wish that Solomon asks for.
Without hesitation, Solomon replies that he wants to be wise, and God accedes to his request. When Solomon wakes, he immediately prepares an offering and sacrifices it.
A short time later, two prostitutes come before Solomon with a perplexing case. Both had recently given birth, and one of the women had mistakenly smothered her child while sleeping, killing it. The other woman accused her of stealing her own baby and replacing it with the dead child; the first woman accused the second of doing the same.
Each presents her story to Solomon, who contemplates the case and then instructs his attendants to bring him a sword. When they do, he orders them to cut the living child in half and present one piece to each mother. One woman cries out to the king, telling him not to kill the child; "Give her [the other woman] the living child; whatever you do, don’t kill him!" (3:26). The other woman is indifferent: "No, it will be neither yours nor mine; cut it in two" (3:26).
Solomon, of course, sees through the lie at once. "On no account kill the child," he instructs his attendants, "Give him to the first woman–she is the real mother" (3:27).
The haftarah concludes with the nation of Israel reverentially hearing the news of King Solomon’s decision: "they saw that he had within him divine wisdom to do justice" (3:28). This cemented his standing among the tribes, and, the story concludes, "Solomon was now king over all Israel" (4:1).