Brazil have secured a place in the final of the Confederations Cup with a 2-1 win over Uruguay.
Uruguay had a chance to take the lead in the 14th minute when David Luiz conceded a penalty for dragging down Diego Lugano in the box, but keeper Julio Cesar was able to push Diego Forlan's spot kick wide.
The host nation punished the miss just before half time as Fred managed to bundle the ball in from close range, pouncing on the rebound from a Neymar effort.
Uruguay were back on level terms within three minutes of the restart, as Edinson Cavani carved a hole in the Brazilian defence to curl a shot into the bottom corner.
It looked as though the game would be heading into extra time until Paulinho headed home Neymar's corner from close range, securing a place in Sunday's final for Luiz Felipe Scolari's men.
Brazil will face either Spain or Italy in Sunday's showpiece at the Maracana Stadium.