Panama beat Bolivia 3-1 on Monday to finish second in Group C and qualify for the Copa America quarterfinals after tournament hosts the United States were eliminated following a 1-0 loss to group winners Uruguay.
The win moved Panama, playing in only their second Copa America, up to second on six points, three more than the US, as the central American side reached the knockout stage for the first time.
Uruguay finished with nine points.
Jose Fajardo, Eduardo Guerrero and Cesar Yanis scored for Panama with Bolivia's lone goal coming from Bruno Miranda.
Bolivia exit the tournament after three straight losses having conceded 10 goals and scoring just one.
Bolivia needed a win with only a slim chance of staying alive in the tournament, but it was Panama who broke the deadlock in the 22nd minute when Cristian Martinez set up Fajardo.
The 30-year-old forward expertly controlled Martinez's header into the box, let it bounce and volleyed the ball past Bolivia goalkeeper Guillermo Viscarra.
Bolivia equalised in the 69th minute when they cut through Panama's midfield and defence, with Ramiro Vaca finding Miranda, who slipped his shot past the keeper.
Bolivia nearly took the lead in the 78th minute when Panama goalkeeper Orlando Mosquera ventured out of the box but Miguel Terceros's long-range effort was thwarted by the retreating Panama defence.
A minute later, Panama wrested back control of qualification when Davis curled in a cross from the left and Guerrero connected with a glancing header - his first goal for his country.
Yanis made sure of victory in the first minute of added time, blasting a right-footed shot into the top right corner after he was put through on goal, sparking wild celebrations at the Inter&Co Stadium.
Defender Mathias Olivera scored to give Uruguay the win. The South Americans won three of their first-round matches for the first time since 1959.
"The pitch was very hard to play on," Uruguay midfielder Manuel Ugarte said.
"But hey, when we have to score, we score; when we have to play, we play. It's a bit of adapting to the matches and the moments of each match."
The defeat has ramped up the pressure on US coach Gregg Berhalter, with fans chanting: "Fire Gregg" in the second half and after the final whistle.
"We know that we're capable of more, and this tournament, we didn't show it," Berhalter told reporters.