Andy Murray survived a major scare against Italy's Fabio Fognini to reach the quarter-finals in Rio.

The 2012 champion had cruised through his opening two matches and another easy win looked on the cards when he led by a set and a break.

But the momentum turned abruptly and Fognini, one of the most talented but unpredictable players on tour, seized his chance.

The world number 40 won eight games in a row to lead 3-0 in the decider before Murray, as he so often does, fought back from the brink to claim a 6-1 2-6 6-3 victory.

In the last eight he will take on American Steve Johnson, who defeated Russia's Evgeny Donskoy.

Fognini was the last man to beat Murray in Davis Cup, when Britain lost to Italy in the quarter-finals two years ago, but facing the 29-year-old on a clay court in Naples was a rather different proposition to a slow hard court on a windy Rio day.

Given what transpired, it was hard to believe how poorly Fognini played in the opening set, with a smattering of boos for the Italian's lacklustre performance.

He at least roused himself to save three set points and avoid a bagel but Murray was on cruise control.

When the Scot broke to lead 2-1 in the second set, he seemed on his way to the quarter-finals with the minimum of fuss, but Fognini found his form and Murray began to make errors.

Five straight games from the Italian brought him level at one set all and left Murray needing to fight hard to keep his medal hopes alive.

Fognini was on the front foot and having a lot of success at the net, and he maintained his form at the start of the third set with a break for 2-0.

Murray had two chances to hit back but could not take them and, had Fognini converted a chance to lead 4-1, the outcome might have been different.

But Murray broke back and the wheels fell off for Fognini as the world number two reeled off six games in a row.

Murray joined Rafael Nadal and Juan Martin Del Potro, who are on course for a semi-final meeting, in the last eight.

Nadal, who has never lost an Olympic singles match having won the title in 2008 and missed out in London through injury, continued his impressive form with a 7-6 (7/5) 6-3 victory over Frenchman Gilles Simon.

The 14-time grand slam champion arrived in Rio having not played a match since the French Open and admitting his troublesome wrist was still not fully recovered.

But he has looked sharp and confident and is still fighting for a medal on three fronts, having reached the semi-finals of the men's doubles with Marc Lopez as well as entering the mixed doubles alongside Garbine Muguruza.

Nadal next plays Brazil's Thomaz Bellucci, whose upset win over David Goffin was celebrated with a huge roar.

Del Potro, the conqueror of Djokovic in round one, lost the opening set to Japan's Taro Daniel but recovered to win 6-7 (4/7) 6-1 6-2.

Big-hitting American Madison Keys was the first woman through to the semi-finals, with the 21-year-old beating Daria Kasatkina of Russia 6-3 6-1.

Petra Kvitova has been in great form in Rio and the Czech blitzed Serena Williams' conqueror Elina Svitolina 6-2 6-0 to set up a last four clash with Puerto Rico's Monica Puig.