After beating Andy Roddick and Rafael Nadal on his way to the final, the third seed claimed the biggest scalp in tennis to secure his fourth title in 2007.
"This is the best tournament of my career," Djokovic told the crowd.
"I won a (Masters) in Miami but here I beat the number three (Roddick) in the quarters, the number two (Nadal) in the semis and in the final, I beat the number one.
"I couldn't ask for more. I played some impressive tennis all week. This is a dream come true. And I hope he's not angry, but I'd like to say to Roger that he can't win everything, sometimes somebody else has to win."
Federer had been the overwhelming favourite to win his third Masters crown in Canada in as many appearances but instead suffered his first defeat in five meetings against Djokovic after producing 48 unforced errors.
The 20-year-old from Belgrade attacked the Federer backhand relentlessly throughout, ripping forehands up the line for a series of winners.
He saved six set points in the first set before snatching it on a tiebreak 7-2.
The Swiss top seed lifted his game in the second set, breaking the Serb twice to level the contest.
Djokovic broke in the opening game of the third set only to let a 4-2 lead slip as the Swiss hit back to 4-4.
But the Serb, who will return to third in the rankings when the new list is released on Monday, held his nerve to win the tiebreak 7-2 and seal his second Masters Series title.
Federer praised Djokovic's performance.
"He is definitely one of the best players in the world and he deserved to win today," he said.