Roger Federer said he was happy to lose a stunning point to Daniil Medvedev in his second-round victory at the Shanghai Masters.

Federer opened his title defence with a hard-fought 6-4 4-6 6-4 win on Wednesday – the 20-time grand slam champion making his first appearance since losing in the fourth round of the US Open.

The former world number one and 37-year-old Swiss superstar advanced but Medvedev produced the highlight of the night in the second set.

Federer was left applauding a remarkable backhand volley on the stretch from Medvedev, which saw the ball land on the Russian's side of the net on the second bounce.

Talking about the shot after the match, Federer said: "What was great about that shot is he didn't maybe want that, but he gave himself the best chance to make the ball.

"When you have the right intention, right belief and right stretch, good things do happen.

"This was one of the perfect examples that we both played a great point, and at the end, a little magic happens.

"It was good fun to see it. In the beginning, you're like, 'I can't believe it happened', then you're actually happy for the guy that he actually pulled off a great shot."

Federer – seeking a third Shanghai trophy – will face Roberto Bautista Agut in the next round.