Cavani put Uruguay ahead in the seventh minute when he evaded the Portugal defence to meet Luis Suarez’s pinpoint cross with a bullet header at the far post.
Pepe headed Portugal level in the 55th minute, the first goal Uruguay have conceded in the tournament, but Uruguay regained the lead seven minutes later when Rodrigo Bentancur found Cavani and he curled a brilliant first-time shot past Rui Patricio from the edge of the penalty area.
Portugal dominated possession but their attack did not have enough bite to break through the Uruguay defence twice, leaving their captain Cristiano Ronaldo a frustrated figure throughout the match
The Real Madrid forward could not add to his four goals in the first two matches, failing to improve his record of failing to score in all six World Cup knockout matches he has played.
Ronaldo had an opportunity around the half-hour mark to score from a free kick 30 metres out but could only hit the wall.