Two-time former champions Argentina advanced after goals from Alexis Mac Allister and Julian Alvarez sealed victory over Poland in Group C while Australia sent sorry Denmark crashing out with a 1-0 victory in Group D.
Argentina - who suffered a stunning defeat to Saudi Arabia in their opening game - ensured they qualified for the second round as group winners in a game in which captain Messi missed the 31st penalty of his career.
“We went out there thinking we had to win,” said Messi, who added that missing his spot-kick had galvanised his teammates.
“I’m angry at missing that penalty but the team came out stronger after my mistake,” he said. “We knew that once the first goal went in it would change the game.”
Messi said Argentina, who will meet Australia in the next round, could not take progress to the quarter-finals for granted.
“The game against Australia will be difficult - anyone can beat anyone,” he added. “It’s very even. We have to prepare for the game in the best way, as always.”
The final round of games in Group C got under way with all four teams - Argentina, Poland, Mexico and Saudi Arabia - in the hunt for the last 16.
Despite losing to Argentina, Poland squeaked into second place, edging out Mexico - 2-1 winners over Saudi Arabia - on goal difference.
For long periods of a nail-biting evening it looked as if Poland’s tally of fewer yellow cards would secure their place in the last 16.
But a goal in the fifth minute of injury time by Saudi Arabia’s Salem Al-Dawsari against Mexico gave Poland a slender one-goal advantage on goal difference - and a place in the second round.
Saudi Arabia’s defeat sealed a disappointing exit for the Asian minnows, who had electrified the opening days of the tournament with their shock opening win over Argentina.
Poland will take on Group D winners France in their last 16 match.
‘A lot of belief’
Australia reached the knockouts for the first time since the 2006 World Cup thanks to Mathew Leckie’s superb 60th minute goal dispatched Denmark.
A second-string France side - already virtually assured of top spot - suffered a 1-0 loss to Tunisia.
Australia coach Graham Arnold said he was “just so proud of the effort by the boys”.
“It was a short turnaround but their effort was incredible. A lot of belief, a lot of hard work,” he added.
“These boys came in with a great mindset. We’ve been working on this for four, four-and-a-half years about the belief, the energy and the focus. I could see in their eyes they were ready tonight.”
After two wins out two, France were already assured of a place in the knockout round at kickoff so coach Didier Deschamps made nine changes to his starting line-up to play Tunisia, leaving stars including Kylian Mbappe among the substitutes.
Tunisia stunned the holders when captain Wahbi Khazri stretched to poke the ball past French goalkeeper Steve Mandanda in the 58th minute at the Education City Stadium.
Deschamps responded by sending on five substitutes, including Mbappe and Antoine Griezmann.
Tunisia stood firm but Griezmann finally had the ball in the net eight minutes into added-on time, driving in a shot through a crowd of defenders.
But just when France thought they had salvaged a point, New Zealand referee Matthew Conger was called over to the VAR monitor and ruled the goal out for offside.
The north Africans’ supporters counted down the final seconds to a famous victory over France that eased the pain of elimination.
“They still had top-class players out there but we were superb and I think the result is down to us,” Tunisia goalscorer Khazri said.
“Unfortunately in football it is better not to have to rely on others for results, but we can go out with our heads held high.”