HOUSTON — The Tampa Bay Rays and Houston Astros both had reasons to like how things turned out Friday night.

Drew Rasmussen and the Rays were the only ones celebrating, however.

Rasmussen pitched seven effective innings, and the Rays clinched a playoff spot for the fourth straight season, posing on the field for a team picture after beating Houston 7-3. Despite the loss, the Astros wound up with home-field advantage throughout the AL playoffs.

The Rays (86-71) began the day in the third and final AL wild-card slot, trailing Toronto and Seattle.

Tampa Bay extended the longest postseason streak in franchise history and earned a playoff spot for the eighth time, all since 2008. The Rays have never won the World Series.

“They’ve withstood some bad news and some bad performances, but they’ve come out on top with some really good performances to stay afloat here,” Rays manager Kevin Cash said. “It feels like right now, we’re coming into our own a little bit. These guys are still young, and we’re getting a taste of some really cool stuff.”

Houston (102-55) was assured home-field advantage throughout the AL playoffs when the New York Yankees lost earlier in the day. Only the Los Angeles Dodgers have a better record than the Astros.

“It’s hard to celebrate when you feel the pain of losing,” Astros manager Dusty Baker said. “We’ll worry about that later.”

Rasmussen (11-7) held Houston to two runs and five hits in seven innings. He entered Friday riding a three-game losing streak, the longest of his career.

“I had a really bad outing against these guys the other day, so to be able to come back and attack the strike zone like I know how to and get quick outs and allow the defense to play was absolutely incredible,” Rasmussen said. “There’s a lot of excitement going into the postseason now, and we’re officially in.”

Yandy Díaz doubled and singled twice, driving in two runs and scoring two. Taylor Walls homered and scored twice for the Rays.

Tampa Bay scored three times in the sixth, taking a 6-2 lead and chasing Framber Valdez (16-6).

Valdez, who saw his MLB-record streak of 25 consecutive quality starts snapped in his previous start, had a second consecutive rough outing. In 5 1/3 innings, he allowed six runs, nine hits and three walks.

Valdez has been tagged for 10 runs in his last two starts after allowing just eight runs in the entire month of August.

“He didn’t have his breaking ball tonight too much,” Baker said. “He actually threw more fastballs than he threw breaking balls. No, I don’t have any concerns for Framber. Framber is fine.”

Former Astro Jose Siri hit an RBI double, and Díaz doubled home Siri and Walls to break it open.

Walls homered in the eighth, his eighth of the season.

The Rays are 4-0 all-time in postseason play as a wild-card team. They won the 2013 wild-card game in Cleveland and 2019 wild-card game in Oakland, and also swept a 2020 wild-card series against Toronto.

The Associated Press contributed to this report.