SEOUL, South Korea — South Korea’s newly elected president vowed on Wednesday to play a more assertive role in resolving the North’s nuclear crisis through dialogue, saying that he was willing to meet with its leader, Kim Jong-un, if the circumstances were right.

President Moon Jae-in also pledged to strengthen the alliance with Washington, expressing an eagerness for an early summit meeting with President Trump, whose military posturing and diplomatic overtures toward the North in recent weeks have both rattled and confused South Koreans.

But Mr. Moon also hinted at balancing diplomacy between the United States and China, his country’s largest trading partner, over the contentious deployment of an American missile defense system here.

Mr. Trump called Mr. Moon hours after he was formally sworn in on Wednesday. The two leaders agreed to maintain a strong alliance and cooperate in dealing with North Korea’s nuclear and missile threats, Mr. Moon’s office said. They also agreed to hold a summit meeting in Washington at the earliest opportunity, it said.