He also said he will “sincerely negotiate” with the United States, Seoul’s top ally, and China, South Korea’s top trading partner.

Newly-elected South Korean President Moon Jae-in said on Wednesday that he was open to visiting rival North Korea under the right conditions to talk about Pyongyang’s aggressive pursuit of nuclear-tipped missiles.

Mr. Moon, speaking during his formal oath of office, also said he’ll “sincerely negotiate” with the United States, Seoul’s top ally, and China, South Korea’s top trading partner, over the contentious deployment of an advanced U.S. missile-defense system in southern South Korea. The system has angered Beijing, which says its powerful radars allow Washington to spy on its own military operations.

In a speech at the National Assembly hours after being declared the winner of Tuesday’s election, Mr. Moon pledged to work for peace on the Korean Peninsula amid growing worry over the North’s expanding nuclear weapons and missiles program.

“I will quickly move to solve the crisis in national security. I am willing to go anywhere for the peace of the Korean Peninsula if needed, I will fly immediately to Washington. I will go to Beijing and I will go to Tokyo. If the conditions shape up, I will go to Pyongyang,” he said.

Mr. Moon, whose victory capped one of the most turbulent political stretches in the nation’s recent history and set up its first liberal rule in a decade, assumed presidential duties early in the morning after the National Election Commission finished counting and declared him winner of the special election necessitated by the ousting of conservative Park Geun-hye.