Boston has won back-to-back games and became the first team in the majors this season with 20 victories.
Ryan Dempster (2-2) gave up a first-inning homer to Brett Lawrie, but the Blue Jays were shut down after that despite putting a dozen runners on base. Dempster lasted six innings to get the win, walking three and striking out four.
Mike Carp singled in a run in the second to tie the contest and Stephen Drew put Boston in front later in the inning with a sacrifice fly.
The other Red Sox run came on an RBI single by Jacoby Ellsbury in the sixth.
Hanrahan allowed a leadoff single in the ninth, but the game ended on a double-play grounder from Munenori Kawasaki. It was Hanrahan's fourth save.
J.A. Happ (2-2) walked seven and gave up two runs on three hits in just 3 2/3 to take the loss.
Duggar sisters unveil Christian dating rules in new book
Handler slams Piers Morgan: 'You're a terrible interviewer'