South Korean voters have overwhelmingly chosen the liberal candidate Moon Jae-in as their next president, an exit poll suggests.
It put Mr Moon on 41.4%, with his nearest challenger, conservative Hong Joon-Pyo, on 23.3%.
Mr Moon favours greater dialogue with North Korea, in a change to current South Korean policy.
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.
A former member of South Korea's special forces turned human rights lawyer, Mr Moon, of the Democratic Party of Korea, 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 earlier on Tuesday.
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.
Mr Moon has talked of reforming South Korea's huge family-run conglomerates, known as chaebols, which dominate the domestic economy.