Image copyright Reuters Image caption President Moon (right) pledged to unify a divided country reeling from a corruption scandal

South Korea's new President Moon Jae-in has been sworn in, vowing to address the economy and relations with the North in his first speech as president.

He said that he would even be willing to visit Pyongyang under the right circumstances.

Mr Moon took his oath of office in Seoul's National Assembly building a day after his decisive win.

The former human rights lawyer and son of North Korean refugees is known for his liberal views.

Tensions on the Korean peninsula remain high and recent weeks have seen the US and Pyongyang trade angry rhetoric as speculation about another nuclear test grows.

Mr Moon has also vowed to unify a divided country reeling from a corruption scandal which saw his predecessor, Park Geun-hye, impeached.

In his inauguration speech, Mr Moon said he would "do everything I can to build peace on the Korean peninsula".

"If needed I will fly to Washington immediately," he said. "I will also go to Beijing and Tokyo and even Pyongyang in the right circumstances."

He added that he would have "serious negotiations" with the US and China over the controversial deployment of anti-missile system Thaad.

In his first key appointments, President Moon named Lee Nak-yon, the current governor of South Jeolla Province, to the post of prime minister, and Suh Hoon, who played a key role in preparing the two inter-Korea summits in the 2000s, to head the National Intelligence Service.

What was President Moon's message? Analysis by BBC's Korea correspondent Stephen Evans

The tone was certainly different.

While ex-President Park sat the election out in a prison cell awaiting trial, President Moon toured Seoul in an open-topped car.

She was reclusive while he is open was the message.

The new South Korean leader said he took office with empty pockets and would leave office with empty pockets and that was different, too - an emphasis that enrichment is not his motive and that politicians and businesses who grease each other's palms have to be stopped.

But tone is easy; hard policy more difficult.

President Moon has signalled that he wants a closer relationship with the North, though he and the people around him were at pains to point out on Wednesday that no negotiations or visit are imminent while a visit to Washington would come soon.

But what happens if Kim Jong-un marches on with his nuclear tests and no amount of soft-soaping will stop him?

North Korea has yet to officially comment on Mr Moon's victory and remarks. It had previously hinted that Mr Moon was its preferred candidate.

The 64-year-old Democratic Party candidate has also promised to bolster the economy and address youth unemployment, which are key concerns for voters.

Who is Moon?

Image copyright Reuters Image caption Mr Moon was met by supporters and neighbours as he left his house in Seoul on Wednesday

The son of refugees from North Korea, Mr Moon served in South Korea's special forces before becoming a human rights lawyer.

Advocates greater dialogue with the North while maintaining pressure and sanctions, in contrast to his predecessor.

Wants to reform South Korea's family-run conglomerates, known as chaebols, which dominate the economy

Jailed while a student in the 1970s for leading protests against military ruler Park Chung-hee, Ms Park's father.

He was a top aide to former liberal President Roh Moo-hyun.

Who is South Korea's new president?

Mr Moon has been critical of the two previous conservative administrations, which took a hardline stance against Pyongyang, for failing to stop North Korea's weapons development.

Since the Korean War ended in an armistice in 1953, there have only been two summits where the leaders of the two Koreas have met, both held in Pyongyang.

Mr Moon spearheaded preparations for the second meeting in 2007, when serving as a presidential aide.

Media playback is unsupported on your device Media caption Moon Jae-In celebrates becoming South Korea's new president at a victory rally

The US, South Korea's most important ally, has congratulated Mr Moon on his victory.

White House press secretary Sean Spicer said the US looked forward to continuing to "strengthen the alliance" and "deepen the enduring friendship and partnership".

Japanese Prime Minister Shinzo Abe said their countries faced common challenges "led by responses to the North Korean issue" but they could "further contribute to peace and prosperity of the region by working together".

President Xi Jinping said he "always attaches great importance to the relationship between China and South Korea", and that he was "willing to diligently work with" with Mr Moon to ensure both countries benefit, reported Chinese state news agency Xinhua.

Image copyright EPA Image caption Mr Moon also visited the National Cemetery on Wednesday morning to pay his respects to war heroes and past presidents

Final results show Mr Moon took 41.1% of the vote on Tuesday, while conservative candidate Hong Joon-pyo took 25.5%.

Centrist Ahn Cheol-soo, widely seen as a strong contender, came third with 21.4%.