Mr Moon is taking on a country reeling from a corruption scandal which saw his predecessor removed from office.
The 64-year-old rights lawyer and economic liberal must also look to shore up a fragile economy and manage tense relations with North Korea.
He has spoken of increasing contact with the North, which would mark a major shift in South Korean policy.
Mr Moon, the Democratic Party candidate, took 41.1% of the vote, with conservative Hong Joon-pyo taking 25.5%.
Centrist Ahn Cheol-soo, who had been widely seen as a strong contender, came third with 21.4%.
Speaking to supporters shortly after his victory was clear, Mr Moon said he would build "a just, united country".
"I will be a president who also serves all the people who did not support me."
He will be sworn in as South Korea's 19th president at a midday (03:00 GMT) ceremony at the National Assembly building, said South Korean media.
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 killed himself in 2009 after leaving office amid bribery allegations.
Mr Moon, of the centre-left Democratic Party, unsuccessfully ran against Ms Park in the 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 internationally, 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.