Panama beat Bolivia 3-1 on Monday to finish second in Group C and qualify for the Copa America quarter-finals after tournament hosts United States were eliminated following a 1-0 loss to group winners Uruguay.
Panama are playing in only their second Copa America and the victory moved them up to second with six points, three points above the US, as the central American side reached the knockout stage for the first time.
Uruguay finished with nine points.
Bolivia needed a win with only a slim chance of staying alive in the tournament, but it was Panama who drew first blood when Jose Fajardo expertly controlled a header into the box, let it bounce and volleyed home in the 22nd minute.
Bolivia equalised in the 69th minute when they cut through Panama's midfield and defence, with Ramiro Vaca finding Bruno Miranda, who slipped his shot past the keeper.
But Panama wrested back control of qualification 10 minutes later when Eric Davis curled in a cross from the left and Eduardo Guerrero connected with a glancing header.
Panama scored again in added time when Cesar Yanis was put through on goal and he volleyed the ball into the top corner to give them a two-goal cushion, sparking wild celebrations at the Inter&Co Stadium.
Uruguay knock-out US
Uruguay defender Mathias Olivera scored to steer his side into the Copa America quarter-finals with a 1-0 win in Missouri on Monday over hosts United States, who were knocked out after finishing third in Group C.
Uruguay finish as group winners after winning all three matches, with Panama beating Bolivia 3-1 to finish second on six points - three ahead of the US
The US, needing a win to give themselves the best chance of progression, started the match with real urgency, but the South Americans grew into the game as the first half wore on and went close to scoring through Darwin Nunez.
The biggest cheer of the night from the crowd at Arrowhead Stadium came in the 64th minute when Bolivia scored an equaliser against Panama in the other Group C match, briefly moving the US. up to second place, but their joy was short-lived.
Just two minutes later, Uruguay took the lead as Olivera bundled in a rebound after U.S. goalkeeper Matthew Turner could only parry Ronald Araujo's header back into the box. The goal was given after a lengthy VAR review for off-side.