Moon Jae-in: South Korean liberal claims presidency
Liberal candidate Moon Jae-in has claimed victory in South Korea's presidential election.
Mr Moon favours greater dialogue with North Korea, in a change to current South Korean policy.
"I will be president for all South Koreans," he told cheering supporters in Gwanghwamun Square in the capital Seoul.
The early election was called after a corruption scandal led to the impeachment of the former president.
Park Geun-hye is accused of allowing a close friend to extort money from companies. She denies all wrongdoing.
With 80% of the votes counted, Mr Moon was ahead with 40% of the total, the National Election Commission said.
His conservative challenger, former prosecutor Hong Joon-pyo, was next with 25.5% followed by centrist candidate Ahn Cheol-soo on 21.4%.
Mr Moon is expected to be sworn in on Wednesday.
Change is coming: analysis by Stephen Evans, BBC News, Seoul
A Moon Jae-in presidency would represent a real shift in attitude towards North Korea. His policy is to increase contact with North Korea, in contrast to the tighter sanctions of the last ten years. He is unhappy about the deployment of a US anti-missile system on South Korean soil.
When Mr Moon was last in government, in the early 2000s, South Korea had a "Sunshine Policy" which meant co-operation with North Korea, a policy which was abandoned as North Korea tested nuclear weapons.
As policy in South Korea looks like shifting, many sceptics remain who think that no amount of talking to Kim Jong-un will persuade him to renounce either his despotic power or his nuclear ambitions.
For the last eight years, Seoul and Washington have been in lock-step over North Korea, with ever tighter sanctions and isolation. That is not Mr Moon's way. Is it Donald Trump's?
Who is Moon?
The son of refugees from North Korea, Mr Moon was jailed while a student in the 1970s for leading protests against military ruler Park Chung-hee - Ms Park's father.
Later, he served in South Korea's special forces before becoming a human rights lawyer.
He served as a senior aide to liberal President Roh Moo-hyun, who committed suicide in 2009 after leaving office amid bribery allegations.
Mr Moon, of the centre-left Democratic Party, unsuccessfully ran against Ms Park in 2012 elections.
He has positioned himself as the man who can move the country on from the scandals of Ms Park's era.
"I feel that not only my party and myself but also the people have been more desperate for a change of government," he said while casting his vote.
What are his policies?
Mr Moon has advocated greater dialogue with the North while maintaining pressure and sanctions, in contrast to Ms Park who cut almost all ties.
He has been critical of the two previous conservative administrations for failing to stop North Korea's weapons development.
But while tensions on the Korean peninsula ensured the election was closely watched, for South Koreans the priority has been corruption and the economy, with youth unemployment stubbornly high.
Mr Moon has talked of reforming South Korea's huge family-run conglomerates, known as chaebols, which dominate the domestic economy.