Two goals from Edinson Cavani earned Uruguay a place in the World Cup quarterfinals as they ended the dreams of Cristiano Ronaldo and Portugal with a 2-1 win in Sochi.
Cavani headed home before the break and, soon after Pepe had headed a second-half equaliser, scored the winner with a superb curling shot.
Portugal had been first to threaten, Joao Mario getting down the left and crossing to the far post where Bernardo Silva could not steer his header on target.
With six minutes gone, Bernardo Silva made progress down the other flank and laid the ball off to Ronaldo, who blasted a first-time effort straight at keeper Fernando Muslera.
But a minute later, Uruguay led when Cavani and Luis Suarez combined in style, Cavani's pass finding Suarez and his cross converted by the striker at the far post, the ball seeming to go in off his face.
At the other end, Jose Fonte steered a downward header across goal and behind, although he appeared to be fouling defender Matias Vecino, and at the other end Suarez saw a cross deflected over after another sharp run had created danger.
Back came Portugal but, after a good spell of pressure, Joao Mario's cross was too deep for Ronaldo and Muslera claimed.
Bernardo Silva and Goncalo Guedes then combined well but the latter's cross was headed clear before it could reach Ronaldo.
As play switched to the other end, Fonte brought down Suarez for a dangerous 25-yard free kick and the forward's low shot was well saved by Rui Patricio.
Ricardo Carvalho's free kick eluded both Ronaldo and Fonte, with the half-hour approaching and Portugal yet to create a clear-cut chance.
Ronaldo then had an opening when Rodrigo Bentancur conceded a free kick for a foul on Guedes 25 yards out, only to blast his effort into the wall.
Martin Caceres and Nahitan Nandez combined to create a chance but the move ended when Cavani was unable to control an awkwardly-bouncing ball, and with five minutes remaining until the break Joao Mario made a promising run down the left only to slip.
In the final moments of the half, with Suarez down following a challenge from Raphael Guerreiro, Portugal won a corner that came to nothing before a half-chance was steered wide by Cavani at the far post.
Diego Godin cleared as Joao Mario sent in the first cross of the second half, and Ricardo put in another that was dealt with by Godin before it could find the waiting Ronaldo.
Guerreiro fired over from the edge of the box after a corner had fallen to him, and then Ronaldo laid the ball back to Adrien Silva, whose shot was deflected behind for a 55th-minute corner.
From it, Portugal were level as Pepe stormed in to head home from Guerreiro's delivery and grab the goal that they had increasingly threatened since the break.
But parity did not last long, Cavani steering a brilliant curling finish into the corner after 62 minutes following Bentancur's beautifully-weighted pass into his path.
Cristian Rodriguez came on for Bentancur as Uruguay made the first change, Portugal taking off Adrien Silva and bringing on Ricardo Quaresma soon afterwards.
With 20 minutes remaining, Bernardo Silva hooked over after Muslera had failed to hold a ball in the area under pressure, and then a Ronaldo strike from outside the box came back off a defender.
Guedes made way for Andre Silva and goal hero Cavani, limping after a knock, was replaced by Cristhian Stuani befoe Guerreiro sent another effort over as the game entered its final quarter of an hour.
Bernardo Silva drove in a low cross that deflected over as Portugal began to run out of time, and then Nandez was replaced by Carlos Sanchez for Uruguay.
Quaresma bent a cross towards Ronaldo, but just over him, and Bernardo Silva's low ball in was cleared before Manuel Fernandes came on for Portugal in place of Joao Mario.
Ronaldo sliced another attempt wide and was booked for protesting after the referee declined to give a foul on Quaresma -- but neither he nor Portugal could find a way through in four minutes of stoppage time as Uruguay held on to their lead to set up a quarterfinal against France on Friday.