Roger Federer recovered from an uncharacteristic out-of-sorts first set to defeat David Ferrer in the third round of the Rogers Cup.

The evergreen Swiss and second seed was in majestic form in the previous round against Peter Polansky, a match that lasted less than an hour, on his first outing since winning a record-breaking eighth Wimbledon title.

However, it was a decidedly more difficult task against fellow veteran Ferrer, who ultimately came up short in a 4-6, 6-4, 6-2 defeat on Thursday.

Federer – a two-time victor of the Masters 1000 event – struggled to find his range in the opening set, sending balls long and putting too many chances into the net and Ferrer soon took advantage for a 3-1 lead.

Ferrer lost his nerve when serving out at 5-3, but Federer failed to make the most of the reprieve and handed the break straight back to surrender the first set.

That snapped a remarkable run of 32 consecutive sets won by Federer, who had seemingly found another gear by breaking Ferrer at the first time of asking in the second.

Ferrer hit back, but this time he failed to build on the momentum as second-seed Federer regained the break lead that he would not relinquish.

And the decider was one-way traffic for Federer, who saw out the win with a textbook serve and volley to set up a last-eight meeting with Roberto Bautista-Agut.