Munmu took the throne in the midst of the long conflict against Baekje and Goguryeo, shortly after General Gyebaek and Baekje had been defeated at Sabi by General Kim Yu-shin. In these struggles, Silla was heavily aided by Tang. The first years of his reign were spent trying to defeat Goguryeo, following an abortive attempt in 661. Finally, in 667, he ordered another attack which led, in 668, to the defeat of Goguryeo. After the small isolated pockets of resistance were eliminated, Munmu was the first ruler ever to see the Korean peninsula completely unified.
Munmu then faced the challenge of freeing his country from Tang domination. After the fall of Goguryeo Tang created the Protectorate General to Pacify the East and placed the entire Korean peninsula, including Silla, under its rule. To prevent this, Munmu forged alliances with Goguryeo resistance leaders such as Geom Mojam and Anseung, and launched a frontal attack on the Tang forces occupying the former Baekje territory. The struggle lasted through the early 670s, but by 676 the Tang forces had been expelled from the peninsula. This victory, and the maintenance of Silla independence, is generally regarded as a critical turning-point in Korean history.
Munmu ruled over unified Silla for twenty years, until he fell ill in 681. On his deathbed, he left his last will and testament, and abdicated to his son, Prince Sinmun. Before he died he said: "A country should not be without a king at any time. Let the Prince have my crown before he has my coffin. Cremate my remains and scatter the ashes in the sea where the whales live. I will become a dragon and thwart the Japanese invasion." King Sinmun did as his father asked, and scattered his ashes over Daewangam (the Rock of the Great King), a small rocky islet a hundred metres or so off the Korean coast. Moreover, King Sinmun built the Gomun Temple (the Temple of Appreciated Blessing) and dedicated it to his father, he built a waterway for the sea dragon to come to and from the sea and land, and he built a pavilion, Eegun, overlooking the islet so that future kings could pay their respects to the great King Munmu.
In a dream, King Munmu and the famous general Kim Yu-shin appeared to King Sinmun and said to him: "Blowing on a bamboo flute will calm the heavens and the earth." King Sinmun awoke from the dream, rode out to the sea and received the bamboo flute Monposikjuk. It was said that the blowing of the bamboo flute invoked the spirits of King Munmu and General Kim Yu-shin and would push back enemy troops, cure illnesses, bring rain during drought and halt the rains in floods.
History often differs from legends. Munmu Wang actually sought political assylum in Japan, where he became Emperor Monmu in 695 by uniting the anti-Tang forces.