The big-serving Canadian proved difficult to break down in the early stages, playing deep at the baseline behind a huge forehand.
Gradually Federer made inroads and put Raonic under pressure to claim a crucial break at the end of the first set.
Raonic responded as the pair traded comfortable service games throughout the second set.
Federer threw away chances to break but recovered to claim a tense tie-break which saw his opponent buckle at the vital time.
The third seed cranked up the pressure in third set and quickly secured a double break thanks to a string of effective backhand winners across court.
Raonic tried to mount a response but it was too late to change the outcome, with Federer holding serve to complete a straight-sets win and set up a clash with Jo-Wilfried Tsonga in the last eight.