The 20-year-old American, who had never beaten Federer before, was down a break and trailing 4-2 in the third, but rallied past the 22 year-old Wimbledon champion 7-3 in the tie-break when Federer double-faulted and made four unforced errors.
Roddick had lost all of their four previous matches and the last time the pair met, Federer cruised past Roddick in the semi-finals at Wimbledon.
Roddick wins first Masters Series
Roddick will meet the winner of the match between Germany's eighth seed Rainer Schuettler, who beat world number one Andre Agassi in the quarter-finals, and 2002 Wimbledon finalist David Nalbandian of Argentina.
Roddick faces Nalbandian in Montreal final
Schuettler ousts Agassi in Montreal quarter-finals