FOXBOROUGH - The Copa America Centenario erupted into controversy on Sunday after a refereeing blunder sent Brazil crashing to a 1-0 defeat against Peru -- and out of the tournament.

The defeat left Brazil struggling to digest their worst performance in the Copa America since 1987, the last occasion the five-time world champions failed to make it past the group stage.

Brazil, needing only a draw to qualify for the quarter-finals as winners of Group B, looked to be on course for a place in the last eight with 15 minutes to go against Peru. But a rare foray into Brazilian territory from Peru ended with Raul Ruidiaz bundling in Andy Polo's cross from the byline, appearing to use his arm to score.

Ruidiaz wheeled away to celebrate and Uruguayan referee Andres Cunha signalled for the goal. Brazil's players protested furiously, swarming around Cunha in a bid to persuade the official to reverse his decision. The protests appeared to have swayed Cunha, who looked to be frantically checking with the fourth official via his headpiece to determine whether the goal should stand.

Yet after a chaotic delay of around four minutes -- with players from both sides surrounding the referee -- Cunha ruled the goal should stand. Multiple replays from different angles, however, showed that Ruidiaz had used his arm to knock the ball into the net past Brazil keeper Alisson.

Brazil pressed forward in the final closing minutes in an attempt to find an equaliser that would take them through but it was to no avail. Elias squandered a golden chance from close range in injury time and Brazil's fate was sealed.

Peru will now play Colombia in the quarter-finals after finishing top of Group B. Brazil coach Dunga lambasted the decision to allow Peru's goal. "I am sure the Brazilian fans saw the game and saw how Brazil was eliminated," Brazil coach Dunga said.

"There is no way to anticipate imponderables. The team was not eliminated by anything to do with football," he added, criticising the lengthy deliberations between the match officials which held up the game.

"I do not quite understand who or what the referee was consulting," Dunga said, adding that he had watched replays of the incident on screens in the Gillette Stadium. "It was such a clear handball, but we have no influence over the referee," he said.

Ecuador set up US showdown after Haiti rout: Ecuador set up a Copa America Centenario quarter-final showdown with the United States on Sunday after romping to a comfortable 4-0 win over Haiti.

Goals from Enner Valencia, Jaime Ayovi, Christian Noboa and Antonio Valencia completed a routine win for Ecuador who are now assured of finishing in second place in Group B. Peru and Brazil play later Sunday with the winner of that game assured of reaching the quarter-finals as group winners.

A draw would leave Brazil, Peru and Ecuador level on five points, but Brazil would advance as group winners with Ecuador second by virtue of their superior goal difference. Ecuador -- making their first appearance in the Copa America quarter-finals since 1997 -- will now travel to Seattle to face the United States at CenturyLink Field on Thursday for a place in the semi-finals.

Haiti, mauled 7-1 by Brazil in their previous game, were given a similarly torrid time by a rampant Ecuador side who attacked at will during a breathless opening period.

Ecuador defender Arturo Mina set the tone for a one-sided encounter, blazing over the bar after only three minutes with the Haiti goal at his mercy. The opening goal came in the 11th minute, Enner Valencia taking advantage of acres of space down the left flank to get behind the Haiti defense before calming tucking away a low finish beneath the advancing Johny Placide.

Enner Valencia then turned creator for the next goal. A superb dummy by Jaime Ayovi allowed the ball to run through to the West Ham player who turned and went clear once more. Ayovi had sprinted into space after his dummy and Valencia unselfishly squared to the striker who tapped into an empty net for 2-0.

Ecuador's large contingent of fans in a crowd of around 50,000 at the MetLife Stadium in New Jersey were made to wait for their team's third goal. It arrived on 57 minutes, Russia-based central midfielder Christian Noboa hammering in a half volley just inside the area to make it 3-0.

Manchester United's Antonio Valencia was the next to get on the scoresheet after Haiti's porous defense was again caught square.  Once again Enner Valencia went clean through on goal and calmly rolled a pass into the path of his namesake who finished for 4-0.