Brazil's Neymar, center, lifts the winner's trophy after the team’s FIFA Confederations Cup final victory over Spain in Rio de Janeiro. (ANTONIO LACERDA/EPA)

Fred scored two goals and Neymar added another as host Brazil defeated world champion Spain, 3-0, to win the Confederations Cup on Sunday night as protesters clashed with riot police outside Maracana Stadium in Rio de Janeiro.

Brazil, a five-time world champion, beat the reigning world and European champion and ended Spain’s 29-game, three-year winning streak in competitive matches.

Fred put Brazil ahead in the second minute, Neymar doubled the lead in the 44th with his fourth goal of the tournament and Fred added his fifth in the 47th.

Brazil, which won its third straight Confederations Cup, has not lost a competitive home match since 1975.

Spain had not lost a competitive game since its 2010 World Cup opener against Switzerland. Yet it had a miserable night against Brazil.

Sergio Ramos sent a penalty kick wide in the 55th and defender Gerard Pique was ejected with a straight red card for fouling Neymar in the 68th.

●ITALY 3, URUGUAY 2: In Salvador, Brazil, Gianluigi Buffon saved three penalty kicks in a shootout and undermanned Italy edged Uruguay, 3-2, to secure third place at the Confederations Cup following a 2-2 draw.

It was a measure of redemption for Italy after a loss to Spain, also in a shootout, in the semifinals.

“The main thing tonight was our character. We showed fantastic character. We never gave up,” Italy Coach Cesare Prandelli said.

Uruguay, meanwhile, has lost seven of eight bronze-medal matches at the World Cup, Copa America and Confederations Cup, including a loss to Germany at the 2010 World Cup.

This shootout capped an entertaining match at the Arena Fonte Nova. Alessandro Diamanti scored one goal and set up another for Italy and Edinson Cavani equalized twice for Uruguay.