Copa do Brasil Wrap: Comebacks aplenty
Gremio, Atletico PR, Goias, Corinthians and Flamengo all trailed heading into their home cup ties, but were able to produce the goods to advance to the final eight.
The other side to progress on Wednesday was Botafogo, who advanced 6-4 on aggregate against Atletico Mineiro after securing a 2-2 away draw.
But it was all about sides coming from behind on Wednesday, with Gremio and Flamengo doing it in the most dramatic fashion.
Gremio trailed Santos 1-0 after the first leg, but were able to square the tie when Souza struck in the 55th minute at the Arena do Gremio.
Santos were looking likely to hold on for extra-time, before central defender Werley scored with just two minutes of normal time remaining to win it for Gremio.
Flamengo trailed Cruzeiro 2-1 heading to their home leg, and were kept at bay for the majority before Elias scored in the 88th minute.
The goal meant Flamengo tied it on aggregate at 2-2, but advance on away goals.
Atletico PR had an Ederson brace to thank for their 3-0 second-leg victory over Palmeiras, who had taken a 1-0 lead into the fixture.
Ederson struck on 35 minutes, levelling the tie, before Paulo Baier scored to put Atletico ahead and Ederson's second sealed their progression.
Goias had a 2-0 second-leg win over Fluminense, with Renan Oliveira and William Matheus the goalscorers to offset their 1-0 loss in the first 90 minutes.
Corinthians had to arrest a 1-0 deficit from the opening leg against Luverdense, but were in front by half-time in the second leg as goals from Alexandre Pato and Fabio Santos fired them to a 2-0 win.