Petro, a former member of the M-19 guerrilla movement who has vowed profound economic and social change, had 40.3% of votes, national registry office tallies showed, with 99.9% of ballot boxes counted.
Hernandez, the septuagenarian former mayor of Bucaramanga, who has promised to fight corruption even though he is under investigation for graft, won 28.2%.
Surveys ahead of the first round showed Hernandez - who now has the support of third place candidate Federico Gutierrez and likely many of his supporters - would lag just a few points behind Petro in a run-off vote.
Petro, a 62-year-old former mayor of Bogota, has consistently led opinion polls on promises to redistribute pensions, offer free public university and begin to change what he says are centuries of profound inequality.
"What's not in doubt today is change," Petro told cheering supporters in central Bogota. "Now it's about seeing what we will do with Colombia, what Colombian society wants for it's own country."
"Corruption isn't fought with slogans on TikTok," Petro added, a jab at Hernandez's popularity on the social media app.
Petro has promised to fully implement a 2016 peace deal with the FARC rebels and seek peace talks with the still-active ELN rebels, as well as halt all new oil and gas development.
"People are showing they are tired of the same thing, that they want a change," said sound engineer Cristian Riano, 35, before listening to Petro's speech.
That sentiment was backed by Daniela Cuellar, senior consultant at FTI Consulting in Bogota, who said Colombians' thirst for something different was clearly demonstrated now the two candidates promising change were heading to the run-off.
"This election is not about Petro, or a move to the left," she told Reuters. "This is about the Colombian population being tired of the traditional political class and are seeking a better life."
Youth are a major demographic for Petro, who had about 50% support in opinion polls from the country's youngest voters.
His campaign ramped up efforts to encourage youth turn-out in the last few days, acknowledging that young people may need an extra push to vote over a holiday weekend.
Petro has rejected oft-repeated accusations he will mimic the policies of deceased former Venezuelan President Hugo Chavez and his successor Nicolas Maduro.
He says it is his opponents - who he accuses of making the country reliant on oil income and of brutality toward anti-government protesters - who most resemble the Venezuelan leaders.
Hernandez rose in the polls only in the last two weeks, boosted by his colorful social media presence.
He has promised to end privileges for officials and govern frugally.
"Today we know citizens have a firm will to end corruption as a system of government," Hernandez said in a video on social media. "The gangs who thought they would govern forever lost today."
Despite Hernandez's rhetoric, he is facing a graft investigation by the attorney general's office over allegations he intervened in a trash collection tender when he was mayor to benefit a company his son had lobbied for.
Hernandez denies the accusations and insists they are designed to derail his presidential bid.
Supporters said his anti-corruption ideas were more important than the investigation against him.
"I think he's a new person, a person for change," Miguel Ciendua, 49, a karate instructor in central Fusagasuga, told Reuters. "Getting out of corruption will improve everything else."
Hernandez's whimsical TikTok videos belie his personal suffering amid Colombia's nearly 60 years of war.
His farmer father was held by the FARC guerrillas decades ago, while his daughter Juliana was kidnapped by the National Liberation Army (ELN) rebels in 2004 and is believed to have been murdered in captivity.
Hernandez has said he would explore peace talks with the ELN, continue to fulfill the FARC deal, strengthen law and order and create jobs, though details of his plans have been scant.
He spent election day with his family and his campaign shared a video of a swimsuit-clad Hernandez receiving a painting made by his young granddaughter.
Opinion polls had predicted that center-right Gutierrez, the former mayor of Medellin, would go to a second round.
Gutierrez, who struggled to push back on accusations he is an ideological successor to unpopular President Ivan Duque, told supporters he would back Hernandez, repeating his assertion that Petro's plans are a danger to the country's future.
Turn-out was 21 million people, out of 39 million eligible voters. It was similar in percentage terms to the first round of voting in 2018, with about some 54% of eligible voters participating.
(Reporting by Oliver Griffin, Carlos Vargas, Nelson Bocanegra, Luis Jaime Acosta and Julia Symmes CobbWriting by Julia Symmes Cobb and Luis Jaime AcostaEditing by Grant McCool, Christopher Cushing and Michael Perry)
By Oliver Griffin, Carlos Vargas and Nelson Bocanegra