Chile was on track to progress to the quarter-finals as group winner with the match petering out for a draw until Cavani glanced a header past Gabriel Arias eight minutes from the end in Rio de Janeiro.
Cavani's header on Monday saw Uruguay leapfrog Chile and earn a quarter-final clash against Peru, with La Roja set to meet Colombia in the last eight.
Playing in front of a sea of red in Rio, Chile enjoyed more of the possession in the lively opening 45 minutes as Charles Aranguiz and Alexis Sanchez forced Uruguay goalkeeper Fernando Muslera into diving saves.
Uruguay – the first nation to play 200 Copa America matches – managed to get in behind Chile's defence via Luis Suarez, who rounded Arias, but he was forced to an acute angle and eventually closed down.
Martin Caceres then volleyed just wide of the post from a corner two minutes before half-time – set-pieces continuing to be Uruguay's most threatening option.
Oscar Tabarez – who became the first ever head coach to reach 200 games in charge of the same nation – and his counterpart made changes but both Uruguay and Chile looked disjointed in the second period.
Uruguay and Chile lacked creativity and penetration but there was no shortage of physicality, though Jose Gimenez cleared Paulo Diaz's goal-bound header off the line to deny La Roja with 20 minutes remaining.
And against the run of play, Uruguay stunned Chile as Cavani popped up and directed a Jonathan Rodriguez cross into the net in the 82nd minute.
What does it mean? Chile's task made difficult
La Roja only needed a point from their final group fixture to win the group but Cavani and Uruguay had other ideas. The result means Chile will now come up against Colombia, who posted a 100 per cent record in Group B, in their bid for a third successive title. Uruguay, meanwhile, face a Peru side that were routed 5-0 by Brazil.
Cavani steps up
Uruguay needed a hero in front of a pro-Chile crowd and Cavani stepped up. His late winner made the nation's passage to the semi-finals a little easier.
Chile fail to capitalise
The match felt like it was played in Chile, such was the sea of red in Rio. But the holders were unable to take advantage on the pitch – ending a run of three successive wins.
Uruguay will take on Peru in Salvador on Saturday, while Chile are scheduled to play Colombia in Sao Paulo a day earlier.