Updated

Peru stunned Brazil 1-0 Sunday night, eliminating it from Copa America on a late goal by Raul Ruidiaz that may have been a hand ball.

Peru beat Brazil for the first time in 31 years to win Group B and will face Colombia in the quarterfinals on Friday.

Dominated for most of the game, Peru's Andy Polo managed a takeaway and crossed to Ruidiaz in the box. He deflected the ball into the net, and Brazil keeper Alisson immediately complained the ball also made contact with Ruidiaz's hand. After a lengthy discussion by referees, the goal was allowed in the 75th minute.

Peru had 10 losses, six draws since 1985) Brazil is eliminated after reaching at least the quarterfinals of every Copa America since 1993.

The group stage loss also could put the job of Brazil manager Dunga at risk.

Ecuador locked up second place in Group B with its 4-0 win over Haiti in Sunday's early game, and will play Group A winner United States on Thursday in Seattle.

Ruidiaz's goal came just about 10 minutes after he subbed in for Edison Flores.

Brazil made a handful of lineup changes, starting Lucas Lima in place of suspended midfielder Casemiro. In addition, defender Miranda got the nod over Marquinhos, and forward Gabriel Barbosa started in place of Jonas.

Brazil controlled the pace in the first half, but wasn't able to complete any of its attacks all night.

In the 27th minute, Elias found Barbosa with a quick cross, but goalkeeper Pedro Gallese got enough of his fingertips on the ball to tap away Barbosa's left-footed shot toward the left corner of the net.

Then in the 36th minute, Filipe Luis got the ball to a cutting Willian as he found some space at the top of the box. Willian couldn't get off a controlled shot, though, and his attempt sailed wide left.

Gallese came through again a few minutes later, deflecting another Barbosa shot over the top of the crossbar.

Peru had no shots on goal in the first half and struggled to set up chances. Meanwhile, top scorer Jose Guerrero battled through a pair of collisions that sent him to the turf.

In the second incident, in the 29th minute, Guerrero needed attention from the training staff after he was sent to the ground by a knee to the midsection from Gil, and then was kicked in the leg as he tried to clear the ball.

Peru's best scoring opportunity came in a flurry just before the end of the half when Flores got free in box, and appeared to be tripped by Miranda but didn't receive a foul call.