Both Cleveland pitchers did an excellent job of that.
"An excellent pitching performance," Indians manager Manny Acta said. "Masterson was impressive. He established his fastball the whole game, was able to throw it to both sides of the plate. He did a magnificent job."
Vinnie Pestano worked the eighth and All-Star closer Perez finished for his 25th save in 27 chances save as the Indians wrapped up their sixth shutout of the season.
"I was sharp tonight, for sure," Perez said. "The slider was coming out good."
Hafner provided the only run Cleveland would need when he led off the second with a towering drive to right, his eighth.
"It was high and just kept on going," Masterson said of Hafner's booming shot. "That was pretty impressive. He's a big boy."
The Indians put runners at second and third in the fourth when Carlos Santana walked and Michael Brantley doubled, but Blue Jays left-hander Ricky Romero struck out Lou Marson and got Johnny Damon to ground out.
Masterson (6-8) was hit hard in his final start before the All-Star break, allowing eight runs and nine hits in 4 1/3 innings on July 6 in a loss to Tampa Bay, an outing that raised his ERA by nearly half a run. But the right-hander bounced back strong against the Blue Jays, giving up just five hits, all singles. He walked one and struck out five.
"It was good that he got back on the horse again and had a good outing against a good hitting ballclub," Acta said.
Masterson said spending the All-Star break at home helped him put the Tampa Bay performance out of his head.
"I don't think I thought about baseball at all," he said. "I maybe caught a hair of some of the All-Star festivities but it was just nice to relax, just sit back and kind of do your own thing. I had a nice date night with my wife, ate at a little Italian restaurant. It was cool."
Toronto didn't put a runner in scoring position until the fifth, when Yunel Escobar reached on a two-out infield single and moved to second on a wild pitch. Kelly Johnson ended the inning by grounding out.
The Blue Jays put two runners on in the seventh, when Edwin Encarnacion walked and Adam Lind singled, but Masterson escaped by striking out Escobar looking and getting Johnson to ground into a fielder's choice.
Like Masterson, Perez was eager to wipe away the memory of his most recent outing, a blown save against Tampa Bay in the final game before the break that snapped his streak of 24 straight saves. His only other blown save came opening day, when the Blue Jays rallied in the ninth to deny Masterson a victory, finally winning in 16 innings.
"The way I look at it is, Sunday was an aberration," Perez said. "I blew a save; it happens. I didn't want to blow another one for him like I did on opening day."
"I thought that first one (by Rasmus) was out of here but luckily we've got a big enough yard to keep it in," Perez said.
Romero (8-5), who came in 0-3 with a 10.80 ERA in his past three starts, has not won since June 22 at Miami. He allowed one run and six hits in six innings, walked two and struck out six.
"Any time you lose it's frustrating, whether you lose 10-0 or 1-0," Romero said. "I've always said I'm a sore loser. I hate losing."
The Blue Jays have scored just three runs in Romero's past three starts, and have not scored in his past 13 innings.
Blue Jays RHP Brandon Morrow (strained left oblique) threw a 25-pitch bullpen session Friday, his first since his June 11 injury. Morrow, who will throw another bullpen Monday, is not expected back before mid-August. ... Toronto RHP Sergio Santos (shoulder) threw a bullpen at Toronto's spring facility in Dunedin, Fla. on Thursday. Santos, out since April 21, will throw another bullpen Saturday. ... Toronto RHP Drew Hutchison (elbow) is due to resume throwing on July 23, manager John Farrell said. Hutchison was injured June 15. ... The Blue Jays purchased the contract of Double-A LHP Aaron Loup and placed LHP Luis Perez (elbow) on the 60-day DL, retroactive to July 9. ... Friday was Cleveland OF Shin-Soo Choo's 30th birthday. ... Indians 2B Jason Kipnis was caught stealing in the sixth, snapping a streak of 18 successful stolen base attempts. ... This was Cleveland's first 1-0 road win on a solo homer since May 26, 1992 at Oakland, when Mark Lewis went deep for the Indians.