The United States beat North Korea 1-0 to finish top of Group G with nine points and will play New Zealand in their last-eight match after the Kiwis beat Cameroon 3-1 to advance. The U.S. and Britain finished the group stage with a perfect record and, like Brazil, had already qualified before Tuesday.
Playing in front of more than 70,000 fans at Wembley Stadium, Britain fired up the crowd by taking the lead after just 90 seconds. Karen Carney dribbled past three players before slipping the ball to Stephanie Houghton, who shot past Brazil goalkeeper Andreia for what proved to be the winning goal.
"We were not paying attention and not so awake, and they scored and protected this until the end," said Brazil striker Marta, who was largely held in check apart from hitting the post in the first-half.
Andreia saved a second-half penalty from veteran striker Kelly Smith to keep the South Americans close in a carnival-like atmosphere but the hosts ultimately prevailed to win Group E in front of the third-largest crowd to ever watch a women's game.
"There is a danger of people jumping on us now as a possible for a medal," Britain coach Hope Powell said. "We're not in a position to get a medal yet and we have still got a job to do."
At Old Trafford, nearly 30,000 fans were on hand to see Abby Wambach's goal in the 25th minute secure the win for the Americans.
North Korea, which finished the match with 10 women after Choe Mi Gyong picked up two yellow cards, still had a chance to advance depending on New Zealand's result later in the day. But goals from Rebecca Smith, Ysis Sonkeng and Sarah Gregorious at the City of Coventry Stadium gave the Kiwis a superior goal difference.
"It's now or never — lose and you go home," Wambach said. "We came here for the gold medal and that's what we want to go home with."
The French finished second in the group with six points, three behind the U.S., after eliminating Colombia from the tournament with a 1-0 win in Newcastle on Tuesday.
Now, they will be seeking revenge at Hampden Park after losing to Sweden at the World Cup in Germany to finish third at the tournament.
"We know we will play Sweden, but more importantly we're delighted to qualify," midfielder Laure Boulleau said.
Canada had to fight back for a 2-2 draw against Sweden at St. James' Park to reach the quarterfinals, and will next play Britain in Coventry.
Sweden scored twice in two minutes with goals from midfielder Marie Hammarstrom in the 14th and forward Sofia Jakobsson in the 16th. Sweden finished first in Group F with five points, ahead of Japan on goal difference, and had already qualified for the next round. Canada finished third with four points.
"Everyone in this tournament is beatable," Canada midfielder Kaylyn Kyle said. "To be the best, you have got to beat they best and they are the best for a reason."
The Swedish will have to lift their spirits quickly after letting a two-goal advantage slip away.
"We have a good mood in the group and we're all well and confident, so there won't be a problem picking ourselves up," said forward Sofia Jakobsson, who scored Sweden's second.
Japan failed to score for a second consecutive match, drawing 0-0 with South Africa, which exits the tournament. Having already secured a quarterfinal spot, Japan coach Norio Sasaki began the match with just four regular starters.
"It was the coach's instruction that we wanted to stay in Cardiff and come second in the group, so I knew that the bench were getting information about the other match and I had been told," Japan defender Azusa Iwashimizu said. "It is something we needed to do in order to get a medal."
Japan's senior women's team beat the United States last year in Germany to win the World Cup. The under-23 team is now seeking to win its first Olympic medal, and it will need to quickly improve to have a chance.
All of the quarterfinal matches will be played on Friday.