Brazil and Portugal couldn't break through in Durban, but each advances to the knockout stage of the FIFA World Cup after a scoreless draw.
The results of the final two groups to complete their three games on Friday set up Round of 16 matchups of continental rivals.
Brazil wins Group G with seven points after winning its first two, and will play Monday afternoon against Chile in Johannesburg (CBC, CBCSports.ca, 2 p.m. ET).
Portugal finished with a win and two draws, putting the country into a Tuesday afternoon slot against Spain in Cape Town.
"Portugal advanced with merits and now we have to start thinking about our next matches," coach Carlos Queiroz said. "It was a difficult match for Brazil and for us."
Brazil and Portugal, which share a language, a history and a soccer flair, failed to produce many fireworks at Moses Mabhida Stadium. The match featured a rash of cards for fouls and simulation. Seven yellow cards were meted out in the first half alone.
"We played to win, but our opponent didn't," Brazil coach Dunga said. "We always tried to attack, but they only tried to take advantage of our mistakes."
Perhaps the best chance came in stoppage time when Brazil's Ramires took a shot that required Portuguese keeper Eduardo to leap back and knock the ball away with one hand.
Portuguese star Cristiano Ronaldo made a pair of inspired runs in the second half, but neither resulted in a shot on target for his side.
"Portugal came playing back, trying to use Cristiano Ronaldo on the counterattacks," Julio Cesar said. "It was a difficult group, so it was good to finish first. Now the hard part begins and we can't lose anymore."
Julio Baptista and Daniel Alves replaced Kaka and Elano for Brazil in the starting lineup. Coach Dunga also brought in Nilmar for Robinho.
Shot skims post
Nilmar nearly rewarded Dunga's move midway through the half, taking a setup by Luis Fabiano near the Portugal net. His shot went off Eduardo's hands and nicked the post.
Kaka was ineligible after receiving a red card against Ivory Coast while Elano has failed to recover from a right ankle injury.
Portugal was without Brazil-born playmaker Deco for the second match in a row because of a right hip injury. Coach Carlos Queiroz made four changes to the team that routed North Korea 7-0 in the previous match, including Duda, Danny, Pepe and Ricardo Costa in the starting grid.
Daniel Alves got off a hefty shot in the sixth minute for Brazil, but not on target.
Until Nilmar's chance, the two sides often resembled wary heavyweight boxers instead of offensive powerhouses.
There was a prime scoring chance at the other end of the pitch just seconds after Nilmar's close call, but after minimal contact in the Brazil box, it was Portugal's Tiago who got the yellow card for simulation.
Dude, Pepe and Fabio Coentrao also got carded for Portugal. Fabiano, Juan and Felipe Melo were the Brazilians cited.
Fabiano headed across just wide of the post in the 39th, and it appeared Brazil was the most likely to score the game's first goal.
But Portugal had the edge in play in the second until the late chance from Ramires.
Ronaldo's first strong run in the final half came down the left side, but he was cut off before getting a shot off. He later dashed down the right side and threaded a pass to Raul Meireles, who shot just wide of the net Julio Cesar was guarding.
It was the first time the teams have met at the World Cup since Eusebio helped the Portuguese beat the Brazilians 3-1 in 1966.