Raonic hit back from 4-1 down in the final set to win the match 6-3 6-7 7-6 and hand Murray his first defeat since he won the US Open.
Raonic broke Murray's serve to love in the opening game of the match and he held on to that advantage to win the first set 6-3.
The second set was a competitive affair that went to a tie-break, but Murray seized his opportunity at 6-5 to take the match into a decider.
Murray broke Raonic's serve for the first time in the match to take a 3-1 lead but he failed to cement the break as Raonic hit back to draw level at 4-4.
Two double-faults from Raonic handed Murray two match points but he failed to convert either of them as the match entered a second tie-break.
The first seven points went with serve but Raonic struck twice at 4-3 to set up two match points.
Murray saved the first thanks to another Raonic double fault, but he could only see a shot drift long on the second to gift the Canadian the win.