Brazil beat hosts France 1-0 in Nantes to reach the women's Olympic soccer semifinals and extend the top-level international career of legendary forward Marta.
Marta, a six-time women's world player of the year, was suspended for the quarterfinal after receiving a red card in Brazil's loss to Spain in its final group-stage game.
At the time, with Brazil struggling to even make it through the group stage, that looked like being a sad end to the Olympic career of the 38-year-old, who has announced she will retire from international soccer this year.
But after limping through in third place in its group with two losses from three games, Brazil won without the player widely regarded as the best of all time in women's soccer.
Gabi Portilho. got the decisive goal, bursting through two defenders to finish past keeper Constance Picaud in the 82nd minute to the delight of Marta watching on in the stands.
Brazil, with Marta back from suspension, will face a rematch with Spain in the last four on Tuesday and is guaranteed the chance to play for a medal.
Despite all her accolades, Marta has never won an Olympic or Women's World Cup title with Brazil. The team went close twice, winning silver medals in 2004 and 2008.
France paid the price for failing to capitalize on its chances in the first half, with Sakina Karchaoui seeing a 16th-minute penalty saved by Brazil goalkeeper Lorena.
Griedge Mbock Bathy then headed against the bar from a corner in the 39th.
Portilho's goal was Brazil's first shot on target and she then hit the post late on.
Earlier world champions Spain fought back from 2-0 down and advanced to the semifinals by beating Colombia in a penalty shootout.
Spain won 4-2 in the shootout at Stade de Lyon, with Ballon d'Or winner Aitana Bonmatí scoring the decisive spot kick.
Catalina Usme and Liana Salazar failed to score from the spot for Colombia, which had looked set to advance to the last four after taking a 2-0 lead through Mayra Ramírez and Leicy Santos.
Jenni Hermoso had sparked Spain's second-half fightback and Irene Paredes forced the game to extra time with an equalizer in the seventh minute minute stoppage time.
Information from The Associated Press contributed to this report.