The Red Sox had stumbled into second place, losers of six of their last seven games after a hot start to the season. But they had the right man on the mound Friday night.

Jon Lester came a pitch away from a perfect game against the Toronto Blue Jays in a 5-0 victory for the Sox. His only blemish was a double by Maicer Izturis with two outs in the sixth inning.

The lefthander was masterful, striking out five without a walk and throwing 79 of his 118 pitches for strikes. It was the third shutout of his career, the first since July 3, 2008.

Advertisement - Continue Reading Below

Lester no-hit the Kansas City Royals at Fenway Park earlier that season and for a while on Friday, he appeared to be on his way to another historic night against a Blue Jays team that has played poorly all season.

Toronto grounded into 12 outs, their hitters failing to get good swings on Lester, who is 5-0 with a 2.73 earned run average.

Lester retired 10 in a row after giving up the double. Nothing was close to being a hit. The Blue Jays sent only 28 batters to the plate.

Lester struck out Adam Lind for the final out and got a huge cheer from the crowd of 33,606. It was the 10th career complete game for Lester.

It was the first one-hit shutout for the Red Sox since Josh Beckett did it June 15, 2011, against Tampa Bay.

The Sox are 5-2 against the Blue Jays this season, outscoring them, 44-40.

Lester was facing the Blue Jays for the third time this season. The familiarity worked in his favor on Friday.

Lester needed only 58 pitches to retire the first 15 batters in order. Eight came on ground balls as he kept his fastball down and induced contact early in counts.

Brett Lawrie led off the sixth inning with a line drive to center field that Jacoby Ellsbury sprinted in to catch. Colby Rasmus then flied to right field.

Izturis broke up the perfect game with a double down the line in left. He hit a changeup that was low but over the middle of the plate.

After getting applause from the crowd, Lester had to face a new hitter. With Rajai Davis unable to hit because of a strained oblique, Lind struck out to end the inning. That left him 3 of 28 against Lester with 11 strikeouts.

Lester was then perfect for the seventh and eighth innings.

Toronto unearthed Ramon Ortiz to make the start, his first in the majors since 2011. Ortiz, who turns 40 in two weeks, was remarkably good as he held the Red Sox to one run on four hits over five innings. He walked five and struck out one.

It was Ortiz’s first appearance against the Sox since Aug. 31, 2004, with the Angels.

The Sox took a 1-0 lead in the second inning. Daniel Nava drew a walk, took third on a single by Jarrod Saltalamacchia, and scored when Will Middlebrooks grounded into a fielder’s choice.

Middlebrooks grounded to shortstop and Izturis’s throw to second base went awry.

The Sox were otherwise frustrated by Ortiz, who left at least one runner stranded in scoring position in all five innings he pitched, three of them at third base.

Shane Victorino, who has swung the bat well after missing seven games with a strained back, walked to start the third inning. With one out, Ortiz threw away a pickoff attempt and Victorino took second.

The Jays intentionally walked David Ortiz with first base open. It worked as Mike Napoli grounded into a force at second base and Nava flied to center.

Middlebrooks doubled with one out in the fourth inning but didn’t advance. Victorino started the fifth inning with a walk before Dustin Pedroia singled. But Ortiz grounded into a force at second before Napoli grounded into a double play.

Lefthander Brett Cecil started the sixth inning for Toronto and worked around another double by Middlebrooks.

The Sox kept prodding in the seventh inning and broke through.

Ellsbury and Victorino had singles off Cecil before moving up on a wild pitch. Pedroia then capped a seven-pitch at-bat with a single to right field.

The Sox were 0 for 11 with runners in scoring position before Pedroia’s hit.

Cecil struck out Ortiz and the Blue Jays called in righthander Mickey Storey. He struck out Napoli but Nava belted a two-run double high off the wall in center. He has 23 RBIs in 30 games.

Saltalamacchia followed with a double to the base of the short wall in right field and the Sox had a 5-0 lead.