Brad Ausmus shook up the lineup and Detroit responded with its highest-scoring game of the season.

Just a coincidence, perhaps, but the Tigers and their manager will take it.

“You only have so much at your beck and call as a manager, things you can do when an offense is struggling,” Ausmus said. “Not that it was a huge shock with the lineup change, but you hope it’s some type of shock to the lineup system that maybe has some positive effect.”

J.D. and Victor Martinez both homered, and Justin Verlander pitched impressively into the seventh inning. Ausmus moved J.D. Martinez from fifth to second in the batting order, swapping him with Justin Upton.

J.D. Martinez hit a three-run homer in the second inning. Victor Martinez added a three-run shot of his own in the sixth.

Verlander (2-2) allowed three runs and five hits in 6 1/3 innings, his third straight quality start since allowing seven runs against Pittsburgh on April 11.

Sonny Gray (3-2) lasted only two innings in the shortest start of his big league career. He allowed four runs, two hits and four walks, throwing 65 pitches.

“I’ve been out of the zone more than I’ve wanted early in the season, but until tonight, it hadn’t hurt me. I’ve had some close calls, but I’ve been able to get out of them,” Gray said. “Tonight, I didn’t have anything. I don’t remember a start like this, where every breaking ball I threw was awful and I couldn’t locate anything.”

Detroit had lost seven of its previous nine, scoring more than three runs only once in the prior seven games. Ausmus was hoping something would click if he adjusted the lineup, and Detroit broke through with four runs in the second.

Nick Castellanos led off with a triple and scored on a one-out grounder by Anthony Gose. With his pitch count already mounting, Gray allowed J.D. Martinez’s homer to right-center field, which made it 4-0.

Khris Davis hit a long solo homer in the fourth for Oakland. His drive cleared Al Kaline’s No. 6 on the brick wall beyond the bullpen in left-center and would have traveled 449 feet unimpeded, according to MLB’s Statcast.

J.D. Martinez drove in another run in the fourth with a sacrifice fly, and Victor Martinez’s homer made it 8-1.

Verlander struck out six and walked two. He had allowed only one run before the seventh, when he gave up consecutive doubles to start the inning and eventually left with one out. One of his runners came home after he exited.

“I would have liked to have gone out there in the seventh and had a quick, clean inning, and get us back in there with no harm,” Verlander said. “It was kind of tough to get loose. I felt like it dropped like 20 degrees that inning.”