Heart of the Swarm starts at a research facility run by Crown Prince Valerian Mengsk, who is performing tests on Sarah Kerrigan to determine how much of her skill at controlling Zerg remains from her time as the Queen of Blades. Jim Raynor is desperate to get Kerrigan away, and shortly after the last round of tests, the facility is attack by Dominion forces. Jim and Sarah embrace breifly before being separated, and Captain Horner is driven off as Sarah returns to the surface to wait for Jim, before learning via a newscast that he was captured and executed by the Dominion.
Enraged, Sarah returns to the Char, discovering her command leviathan. After overpowering splintered swarms on Char, Sarah is visited by Zeratul, who tells her to travel to Zerus, the original homeworld of the Zerg, where the primal zerg are in a constantly evolving state. Sarah, initially reluctant, is convinced after Zeratul tells her that it will give her the power she wants to kill Mengsk. Sarah awakens the oldest living zerg, The Ancient One, and learns that Amon, a fallen Xel'naga, stole a large portion of the zerg from Zerus and created the Overmind from them. Sarah enters a chrysalis in the first zerg spawning pool and emerges, transformed into the primal Queen of Blades.
After absorbing various essences on Zerus, and allying with Alexei Stukov, Kerrigan assaults a Dominion research station to face the hybrid. The scientist leader, Dr. Narud, is later revealed to be a ancient shapeshifter who seeks to resurrect Amon. After being defeated by Kerrigan, Mengsk informers her that Raynor is still alive and Mengsk uses him to threaten Kerrigan. Nevertheless, Kerrigan manages to rescue Raynor from a prison ship while refueling on a station.
Prince Valerian understands that his father is beyond redemption, and along with Raynor's Raiders, supports Kerrigan's full invasion on Korhal. After disabling the air defense on the surface and destroying the psi disrupter, Kerrigan finally reaches the palace of Mengsk. Kerrigan and her allies succeed in breaching the palace. Kerrigan confronts Mengsk in his office and is temporarily weakened by the Xel'naga artifact until Raynor's intervention. Kerrigan then annihilates Mengsk with her powers, thanking Raynor before heading back to the leviathan.
In the final scene, the camera pans around space and galaxy while Kerrigan narrates about that she must face her true enemy, fully embracing her role as the Zerg Swarm.