David RossBOSTON — The Red Sox suddenly are firing on all cylinders. It couldn’t come at a better time.

Boston completed a three-game sweep of the Kansas City Royals with a 6-0 win Sunday at Fenway Park. The Red Sox now have won seven of their last eight games, including three straight since the All-Star break, and head into a crucial stretch against three American League East opponents with a whole bunch of momentum.

“There’s a lot of confidence going on right now,” Red Sox manager John Farrell said after Sunday’s win. “Just hearing some of the conversation in and around our team, it’s not anything beyond today, which has been a trademark of this group all last year. We know the position we’re in, but to think beyond today doesn’t really do us much good. I’m confident we’ll continue that approach as we start up in Toronto tomorrow.”

The Red Sox’s next 13 games are against divisional opponents — seven against the Toronto Blue Jays, three against the Tampa Bay Rays and three against the New York Yankees. It represents an opportunity for the Red Sox, who still are six games below .500 (46-52), to make up some ground after a mostly disappointing first half.

“We finished up good at home right before the Houston series (before the break), played well in Houston and now kind of carried that over to this series,” Jon Lester said after Sunday’s win. “You always talk about getting on rolls and playing consistent baseball, and that’s what we’ve been able to do over the past — obviously not including the break — 10 games, 12 games, something like that. It’s been good to see.”

Lester again dazzled Sunday, striking out eight and allowing just four hits over eight shutout innings. The Red Sox, whose pitching has been solid all season, have posted a 2.25 ERA over their last eight games. Boston has allowed just five total runs over its last four games, which include two shutouts.

The major development has been the emergence of the offense, which received contributions from all over the place Sunday. Brock Holt, Daniel Nava, Shane Victorino and Jackie Bradley Jr. each had two hits. Nava drove in three runs and David Ross drilled his sixth homer of the season.

“If you can create some runs or some offense in that bottom third (of the order), typically you’re going to realize in that top half of the order (that) if they perform to their capabilities, you’re looking at a day you’re going to put up five, six, seven runs as a possibility,” Farrell said. “And that was the case today.”

The Red Sox, whose offense struggled for nearly the entire first half, are hitting .291 (78-for-268) over their last eight games. They have a plus-25 run differential — 43 runs scored versus 18 runs allowed — in that span and look much more dynamic. Boston even is producing timely hits, with Xander Bogaerts, Jonny Gomes and Mike Napoli each hitting big home runs over the weekend.

The Red Sox seemingly understood they needed to turn things around quickly to stay alive and fend off potential wholesale changes to the roster. The challenge only gets tougher from here, but Boston is better-equipped to handle the adversity than it was a couple of weeks ago.