Cavani struck in the seventh minute of Saturday's last-16 tie in Sochi to put Uruguay in control, but Portugal hit back after the interval when Pepe headed home Raphael Guerreiro's cross.
However, Uruguay soon led again when Cavani curled in a peach of a finish, though his delight soon turned to anguish as the striker limped off - aided by Ronaldo - after appearing to pull a muscle.
Portugal pressed in search of a second equaliser but Bernardo Silva missed their best chance to level, screwing off-target when faced with an open goal after Fernando Muslera dropped a cross into his path.
Oscar Tabarez's men can now look forward to facing France in Nizhny Novgorod, with Ronaldo and Portugal unable to follow up their surprise success at Euro 2016 two years ago.
2 - Since 1954, there have only been two players to score a brace for Uruguay in a World Cup knockout game:— OptaJohan (@OptaJohan) June 30, 2018
Luis Suárez in 2010
Edinson Cavani in 2018
Uruguay's previous five goals at Russia 2018 all came from set-pieces but they opened the scoring in the seventh minute with a goal of the highest quality.
Cavani switched play from right to left with a sweeping pass out to Suarez, who teased his man before delivering a wonderful cross his strike partner crashed home at the back post.
Replays, however, indicated Cavani did not make a clean contact with the finish, appearing to propel the ball over the line via his face, rather than with his forehead as intended.
Suarez was close to adding a second with a 21st-minute free-kick but Rui Patricio was alert to beat away the low strike, before Ronaldo hit the wall with a set-piece opportunity at the other end.
Uruguay had not conceded in any of their six matches in 2018 but nearly 10 hours of resistance came to an end courtesy of a simple set-piece move in the 55th minute.
A short corner was worked to Guerreiro and Uruguay did not respond to the threat, the left-back delivering a superb cross that defender Pepe finished brilliantly with a downward header.
Parity was short-lived, though, as Uruguay reclaimed the lead just seven minutes later.
Rodrigo Bentancur collected the ball around 30 yards out and slipped the perfect pass out to Cavani on the left side of the penalty area, allowing Paris Saint-Germain's record scorer to curl a gorgeous first-time strike across Wolves' new signing Patricio.
Bernardo Silva ought to have scored a second Portugal equaliser but blazed off-target with the goal gaping after Muslera’s mistake, with Cavani seeming to pick up an injury in the scramble.
Fernando Santos threw on Andre Silva as Portugal tried to find a way through, but defensive duo Diego Godin and Jose Gimenez held a frustrated Ronaldo at bay, the Portugal captain picking up a late booking for dissent as his emotions ran overboard in the closing stages.
Atletico Madrid pair Godin and Gimenez will hope for a similar outcome when they come up against club colleague Antoine Griezmann in Friday's quarter-final against France.
Key Opta stats:
- This is the first time Uruguay have won their opening four games to a World Cup tournament since 1930.
- Portugal have now lost their last four World Cup matches in the knockout stages of the tournament, since a goalless draw with England in the 2006 quarter-final.
- This was Cristiano Ronaldo’s 38th game in World Cups/European Championships – no player has played in more across the two competitions (level with Bastian Schweinsteiger).
- Ronaldo has played 514 minutes of football in the knockout stages of the World Cup, but has failed to score or provide an assist.
- At 35 years and 124 days, Pepe became Portugal’s oldest ever scorer in a major tournament match (World Cup and European Championships).