BOSTON – Mired in a slump, Dustin Pedroia had an MRI on his right knee to see if the knee might be causing his problem.

The test was negative.

The results were positive.

“I think when he had his knee checked out, that was good for him. He knew he wasn’t hurting himself,” Red Sox Manager Terry Francona said Wednesday night after Pedroia homered to help Boston beat the Arizona Diamondbacks, 6-2.

“He’s just a good player. You wind him up and let him go play. He’ll produce.”

Kevin Youkilis also homered, and Jon Lester (8-2) scattered four hits over seven innings to earn his eighth straight victory and send the Diamondbacks to a franchise-record 12th straight road loss.

Rodrigo Lopez (2-6) lost his fourth straight decision, giving up Marco Scutaro’s single to lead off the Red Sox first before Pedroia hit a line drive over the Green Monster for his ninth homer of the season. Pedroia also singled and scored in the third — his fifth multihit night in his last six games.

“I’ve hit my whole life,” he said. “It’s not going to stop.”

But Pedroia began slumping in mid-May, and his average dropped from .305 to .248. He said last Thursday that his knee had been bothering him, and he had an MRI.

The test didn’t show any damage, and the news gave Pedroia the confidence to return to his all-out style of play.

“I’m feeling better. That’s the biggest thing,” he said. “It definitely helped me.”

Lester gave up Justin Upton’s two-run homer in the second, then just two more singles. He struck out seven, giving him a share of the AL lead with 96, but also walked three and hit two batters.

“It’s kind of night and day from inning to inning and batter to batter sometimes,” he said. “Obviously your objective is to win the game and we did that, but there are still things that need to be refined.”

After Ramon Ramirez put two on in the ninth, Jonathan Papelbon got the last out for his 15th save.

Lopez allowed six runs, 10 hits and two walks in seven innings, and struck out three. Sam Demel, acquired Tuesday in a trade with Oakland, made his big-league debut in relief and pitched a perfect eighth.

The Diamondbacks haven’t won on the road since May 17.

“Anytime you lose a game, it’s tough,” Manager A.J. Hinch said. “We certainly haven’t won a game in our gray uniforms in a long time.”

The Fenway Park crowd broke into the now-obligatory chant of “Beat L.A.!” in support of the Celtics, who will play Game 7 of the NBA finals against the Lakers tonight. More surprising was the sound of a vuvuzela — one of the buzzing horns made famous from the World Cup — coming from the stands.

The Red Sox scored two in the third, but Chris Young avoided more damage when he leaped against the center- field wall to take an extra-base hit from Victor Martinez.

The next batter, J.D. Drew, hit a liner to Young’s right, but he couldn’t get to it and played it off the Green Monster. Pedroia scored, then David Ortiz scored on Adrian Beltre’s infield hit to make it 4-2.

Youkilis added a two-run homer in the seventh. It was his 13th homer. Lester is 8-0 with a 2.01 ERA in 11 starts since opening the season 0-2.