OAKLAND, Calif. — Yandy Diaz slugged baseball’s lowest spender into a matchup with the mighty Astros, Charlie Morton silenced the powerful Athletics on the mound, and the Rays beat Oakland at its own game 5-1 in the AL wild-card round Wednesday night.

After playing in just one game since late July, Diaz hit a leadoff homer and went deep again in the third inning. Avisail Garcia hit a two-run drive in the second, and Morton had all the support he needed as Tampa Bay advanced to face the AL West champion Astros in a best-of-five Division Series.

Game 1 is Friday at Houston, which racked up a major league-best 107 wins this season.

“We have a tough road ahead of us, Houston’s a great team, but we played them well this year. It’s going to be a dogfight,” Tommy Pham said.

Pham homered in the fifth for the 96-win Rays, who had the smallest payroll in the majors at $66.4 million. And in a playoff meeting between creative, small-budget teams that make the most of limited resources, it was Tampa Bay that came out on top.

The Rays were unfazed by a towel-swirling Oakland crowd of 54,005 that established a wild-card record, having recently played at Dodger Stadium and on the road against the Yankees and Red Sox in the season’s final two weeks.

Tampa Bay players raced out of their dugout to celebrate when Marcus Semien struck out to end it, and then started putting on fresh playoff T-shirts and caps.

“It’s a beautiful thing having the lowest payroll in baseball and having the success we did,” center fielder Kevin Kiermaier said before the game. “It always feels good to stick it to the man any time you’re able to in this game, and that’s something to be very proud of.”

The A’s have lost nine straight winner-take-all games since 2000, going 1-15 with a chance to advance to the next postseason round. Their only win was in 2006 against the Twins before being swept in the AL Championship Series by the Tigers.

Even a day earlier, Rays manager Kevin Cash wasn’t sure Diaz would play given how much time he missed with a foot injury during the second half of the season.

Diaz returned for the season’s final game at Toronto after being sidelined since July 23. He played in just 79 games this season, 22 of those at first base with 17 starts.

“He probably caught us off guard a little bit with how quickly he turned around over the last five, six days,” said Cash, who started Diaz at first to make sure his best bat against lefties was in the lineup.

“I just was trying to get good pitches to hit and luckily they went out,” Diaz said through a translator.

Pham was impressed.

“Kudos to him. He kept himself game-ready for as long as he’s been down,” Pham said. “We really need him. I’ve been saying it all year — he’s such a good bat, doesn’t strike out much, knows the strike zone. Hits the ball hard.”

Diaz hit the fifth pitch of the night from Sean Manaea over the wall in right-center. Manaea then struck out the side after Diaz’s drive, but was done after two innings.

“That’s kind of our game. They kind of beat us with our game,” Oakland manager Bob Melvin said.