Andy Murray criticised Italy’s Fabio Fognini after an on-court row at the Shanghai Masters, saying: “I’m not having him talk to me like that.”
Federer, 38, dominated the first set against the world number 46 before a tighter second saw the 20-time Grand Slam champion secure victory by claiming the final three points of a tie-break to win 6-2 7-6 (7-5).
Cameron Norrie’s chances of becoming the new British number one are over after losing 6-3 6-1 against US Open finalist Daniil Medvedev in his second-round match.
Dan Evans, 29, will climb above Kyle Edmund in the rankings next week and becoming Britain’s leading male player for the first time – confirmed after former world number one Murray lost his second-round match.
British pair Jamie Murray and Neal Skupski moved into the second round of the men’s doubles with a 6-3 6-4 win over China’s Xin Gao and Zhe Li.
Murray pushes one of the world’s best all the way
Andy Murray is playing his sixth singles tournament since having a hip resurfacing operation – a metal cap inserted over the femur head – in late January and continues to impress as he builds up towards a potential return to Grand Slam singles at the Australian Open in January.
Murray, a three-time Grand Slam champion, tearfully said in a Melbourne Park news conference at this year’s tournament that he was expecting to retire in 2019 because of the pain he was experiencing in his hip.
No player has previously made a singles comeback after a hip resurfacing operation.
While the Australian Open organisers’ claim earlier on Tuesday that the Scot had confirmed to play in Melbourne was somewhat premature, with Murray yet to formally enter, he is continuing to show signs that a return to the upper echelons of the game is possible.
The manner in which he pushed Fognini all the way in a thrilling battle was another major statement.
Fognini, 32, has enjoyed a productive season which has seen him break into the world’s top 10 for the first time and win the Monte Carlo Masters in April.
Murray had two chances to serve out for the biggest win of his comeback – at 5-4 and 6-5 in the decider – but was unable to take either opportunity.
The second attempt came after the row between the players at the changeover, with Murray accusing the Italian of trying to put him off by shouting as he put away a net volley.
Murray remonstrated with umpire Murphy about his opponent’s behaviour, with Fognini laughing during the exchange before being told by the official not to shout during play.
Fognini broke back to level when Murray spooned a backhand wide and then ran away with the tie-break before the pair exchanged a brief handshake at the net after a match that lasted three hours and nine minutes.
BBC tennis correspondent Russell Fuller
Murray was bitterly disappointed to have lost, having won one more point than Fognini, and twice served for the match.
That’s not like him – and probably the legacy of not having been in that sort of position very often over the past couple of years.
But Murray has still made great progress in China, with seven matches played in three weeks.
He will now compete in next week’s European Open in Antwerp, which he expects to be his final individual event of the year.
He will return, though, in November, to play for Great Britain in the new week-long Davis Cup Finals in Madrid.