SEOUL — South Koreans have elected a new president who is wary of the United States and wants to foster warmer ties with North Korea, opening a new and potentially difficult chapter in relations with Washington.

Moon Jae-in of the liberal Democratic Party claimed victory Tuesday night after securing an unassailable lead. With 65 percent of the votes counted, he had 39.6 percent.

His closest rivals, conservative Hong Joon-pyo and centrist Ahn Cheol-soo, had 26 percent and 21 percent, respectively. Both conceded while the votes were still being counted.

“From tomorrow onward, I will serve as your president,” Moon told cheering crowds of supporters in Gwanghwamun Plaza, the central Seoul square where hundreds of thousands of South Koreans held candlelight protests against President Park Geun-hye, leading up to her impeachment and triggering Tuesday’s election.

Moon’s victory will end almost a decade of conservative rule in South Korea and the hard-line approach toward North Korea that had Seoul walking in lockstep with Washington.

While the Trump administration is calling for “maximum pressure” on North Korea, South Korea will have a president who has pledged to resume engagement with the North – including reopening an industrial park that the previous administration said was funneling cash to the regime in Pyongyang.

But analysts said Moon, 64, a former human rights lawyer, is likely to be constrained and more pragmatic in office, playing down the prospects of a serious rift with the United States even if the tone of the relationship changes.

“We still have the alliance, and North Korea still has nuclear weapons. None of these things have changed,” said James Kim, an international relations expert at the Asan Institute for Policy Studies in Seoul.