NEW YORK -- For the last month, loud music has permeated the New York Yankees' clubhouse after victories.

If the Yankees are going to keep the music going and make a postseason push, they will need performances like the ones they received from right-hander Hiroki Kuroda and catcher Brian McCann on Wednesday.

Kuroda pitched seven strong innings and McCann tied a career high with four hits, leading the Yankees to a much-needed 5-1 victory over the Boston Red Sox.

The battery mates helped the Yankees snap a three-game losing streak and win for the third time in eight games. New York (71-66) also moved back to within four games of the Detroit Tigers for the American League's second wild-card spot.

"Every game we play from now on, it's going to be a must-win for us, and I wanted to shift the momentum," Kuroda said through an interpreter.

"It's just good to contribute," McCann said. "We're at that point in the season where we need to win as many games as possible."

Kuroda (10-8) helped the Yankees shift their momentum for one night by allowing one run and four hits. He tied a season high with eight strikeouts and did not issue a walk for the eighth time while picking up his third straight win.

"We needed one badly," New York manager Joe Girardi said. "We lost three in a row and, as I said, this is a very important homestand and we need to win a lot of games."

Coming off an ugly 9-4 loss Tuesday, the Yankees began Wednesday inauspiciously as left fielder Brett Gardner and shortstop Derek Jeter ran into a double play in the first trying to execute a double steal.

McCann helped erase some of the frustration with a two-run home run in the second inning and then followed up his 17th home run with singles in three consecutive innings, including an RBI single that provided the Yankees with their final margin.

It was McCann's 11th career four-hit game and first since July 6, 2013, at Philadelphia. It also gave him 14 hits in his last 40 at-bats, raising his average to .244.

In between run-scoring hits, McCann helped guide Kuroda through another strong outing. The only Opening Day starter not to land on the disabled list, Kuroda never threw more than 18 pitches in an inning and finished at 95 pitches.

"He just had another start that he's had all year long," McCann said. "I feel like he's been consistent day in and day out, pitch after pitch, and he just keeps making them."

At one point, Kuroda had four straight strikeouts and helped himself by picking right fielder Daniel Nava off first in the fifth. He also limited the damage after third baseman Brock Holt's RBI double in the sixth by retiring center fielder Mookie Betts and designated hitter David Ortiz on flyouts.

Kuroda ended his night strong, stranding left fielder Yoenis Cespedes on first by fanning Nava and retiring first baseman Allan Craig.

Besides the big night from Kuroda and McCann, the Yankees also had a sacrifice fly from center fielder Jacoby Ellsbury and an RBI single from Brett Gardner. New York scored five runs for the 49th time and beat the Red Sox for the ninth time in 15 meetings this season.

Rookie right-hander Anthony Ranaudo (3-1), a New Jersey native, allowed three runs and six hits in 5 1/3 innings and was handed his first loss at any level since June 1. He won his last nine decisions for Triple-A Pawtucket and won his first three starts for the Red Sox.

"I was a little disappointed that we lost the game in general, that the team lost the game," said Ranaudo, who grew up a Yankees fan. "I wasn't really worried about my family or friends. It's great that they were here, that they support me and everything like that, but the team is definitely way more important."

The Red Sox lost for the 12th time in 17 games and were held to one run or less for the 27th time.

"On a night where Kuroda absolutely just shut us down, the three runs were really insurmountable at that point," Boston manager John Farrell said.

NOTES: New York INF/OF Martin Prado sat out because of a strained left hamstring that is considered mild and is expected to keep him out for only a day or two. Prado was lifted in the ninth inning Tuesday for a pinch hitter. ... Boston 2B Dustin Pedroia missed his fourth straight game because of concussion-like symptoms, but manager John Farrell believes he could return Friday when the team is back home. Farrell said Pedroia passed the impact test and took early batting practice. ... RHP Brandon Workman was recalled from Triple-A Pawtucket and will start Thursday for the Red Sox. ... New York RHP Ivan Nova started a throwing program last week as he recovers from Tommy John surgery.