With Neymar missing the game due to an ankle injury, the five-time champions laboured for long periods of the match as they struggled to breakdown the determined defensive set up of their Group G opponents.
Bruno Fernandes scored twice to send Portugal through to the knockout stages from Group H with a game to spare after beating Uruguay 2-0.
Cristiano Ronaldo thought he had scored a second-half header although the striker did not get a touch to Fernandes’ cross which ended up in the net.
“The feeling I had was that Cristiano touched the ball,” Fernandes said. “I was passing the ball to him.”
Portugal’s deserved lead came just a minute after a protester had invaded the pitch carrying a rainbow flag and wearing a t-shirt which read “Save Ukraine” and “Respect for Iranian women”.
Uruguay almost equalised when substitute Maxi Gomez hit a post before Luis Suarez missed from close-range – but they were punished in the 90th minute as a VAR check saw Jose Maria Gimenez adjudged to have handled the ball in the area and, with Ronaldo having been brought off, Fernandes tucked away the spot kick.
Vinicius Jnr had looked the most likely to make the breakthrough and saw a second-half strike ruled out by VAR with Richarlison offside earlier in the move.
But with just seven minutes of the 90 remaining, Casemiro latched onto Rodrygo’s smart flick from Vinicius’ pass inside and slammed home with the help of a glancing deflection off Manuel Akanji.
The thrilling 3-3 draw between Serbia and Cameroon earlier in the day means Brazil, with two wins from two matches, are guaranteed a top two spot, although Switzerland – sitting on three points – will need a win in their final group game with Serbia to guarantee their progress. A draw would be enough if Cameroon don’t beat Brazil.
Brazil coach Tite has been criticised for his conservative approach in the past and his decision to bring Fred into his side in the absence of Neymar was an interesting call and one which would have opened him up to scrutiny had his team not secured a win.
They were certainly far from their flowing best in the first half, when all they had to show for their efforts was a tame shot on target from Raphinha and a chance at the back post for Vinicius, who did not connect cleanly with the cross.