SAN DIEGO — All October — all season, really — Tampa Bay Rays Manager Kevin Cash has had the magic touch. But when he needed it most Friday, when Game 6 of the American League Championship Series was very much in doubt, Cash’s latest chess move was like throwing a match in a puddle of gasoline.

That’s not to say it was Cash’s fault. It would be tough to predict Diego Castillo, his most trusted reliever, would allow two inherited runners to score, then two more, in the fifth inning of a 7-4 loss to the Houston Astros. No one prepares for Martín Maldonado sacrifice bunting, George Springer beating the shift with a single, José Altuve cracking a double, then Carlos Correa singling, too, leaving Castillo to stew behind the mound. But that’s just how it went for the Rays at Petco Park.

They were outhit and outpitched, and their usual lifeline — a dominant bullpen — couldn’t carry them to the World Series. They will have one more chance to get there in Game 7 on Saturday. And if they don’t, the Astros will be the second team to overcome a 3-0 deficit in a best-of-seven series. It would be a complete collapse.

“If the roles were switched, it would be a different narrative,” Rays catcher Mike Zunino said. “So we have to keep that in mind that we’re still right in this thing.”

In the guts of Game 5, as it wound toward a walk-off finish, Astros Manager Dusty Baker had one wish: Please, he prayed, let’s get through this without using Framber Valdez. If there were extra innings, Valdez would have jogged in from the bullpen for the 10th. The Astros, had they survived, would have been stripped of their best-case plan. Baker could have been starter-less.

But Correa helped Baker breathe easy. His game-winning homer both extended Houston’s run and kept Valdez on ice. That’s how Valdez, 26, got to face Blake Snell with the season resting on his left arm. Cash stuffed his lineup with seven right-handed batters. In response, Valdez threw six dominant innings to aid a heaving bullpen.

“We’ve had some big moments that have led to many wins in this postseason,” Cash said of his uneven offense, a group that has struggled outside of Randy Arozarena and Manuel Margot. “But we have not had that offense that just continues to put pressure on the pitcher or opposing defense.”

Willy Adames answered that call with an RBI double in the second. The issue was that no one else did until Margot clubbed two late homers to dent a sturdy deficit. And once the fifth came and the Astros leaped on Castillo, the Rays needed that jolt. Snell exited after yielding a leadoff walk and a slow-rolling single. He used 82 pitches to record just 12 outs. Then Castillo, the guy Cash taps when the pressure spikes, was thrust into a two-on, no-outs jam.

One run would have been a little victory for Tampa Bay. Houston scored four.

“I felt like the most pivotal moment of the game was right there in the fifth inning when they got to first and second on us,” Cash said of hooking Snell, a former Cy Young Award winner, for Castillo. “At that time, I felt like Diego was the right guy to come in there and calm that situation down.”

“It’s one of those things where the situation dictated it,” Zunino added of the move. “It just didn’t work out in our favor.”

“I was confused for sure,” added Snell, acknowledging that he always wants the ball. “But that’s what he thought the best call and decision was.”

Maldonado, the Astros’ catcher, greeted Castillo with a well-placed sacrifice bunt. It appeared like a dinosaur crashing a matchup of two teams that have spearheaded the sport’s analytics movement. Yet it put runners on second and third with one out, and the Rays shifted three infielders to the left side of second base. If Springer pulled a grounder, they were primed to keep Yuli Gurriel on third. If he went the other way — if Castillo missed the low-and-inside target from Zunino — then the Rays were beaten.

So the dam broke with a backfiring plan: Castillo put a sinker on the outer half, and Springer stayed on it and poked a single where a second baseman typically plays. Two runs scored. The Astros took a lead they never lost. Altuve followed with an RBI double into the left field corner. Then, after Castillo walked Michael Brantley, Correa capped the rally with a run-scoring hit to left.

Castillo entered the postseason with a 1.66 ERA in 21⅔ innings. He entered this game with a 0.00 ERA in the postseason. In that same vein, the Rays’ bullpen had yet to allow an inherited runner to score in the playoffs. Each statistic favored Cash turning to Castillo in that moment. That just can’t always account for how the other side will fare.

Because that offense Cash described — unrelenting, unfazed, shoving pressure on the opponent — is what the Astros have right now. It’s what happens when Springer, Altuve, Brantley, Correa and Alex Bregman are the first five hitters of an order. That’s what the reeling Rays are up against.

“Their lineup is fully capable of having crooked-number innings, and that’s what took place,” Cash said. “It’s not an ideal feeling. It certainly didn’t feel good.”

Valdez, to his credit, was the pitcher Baker hoped for. He got 15 swings and misses with his curveball. He threw it 52 times while holding the Rays to three hits. A fifth-inning strikeout had Zunino snapping his bat over his knee. In the sixth, after Kyle Tucker homered off Rays rookie Shane McClanahan, Yandy Díaz and Valdez exchanged shouts after Valdez walked him and asked to appeal a checked swing.

The umpires and Correa stepped between them. The drama came and went. Valdez soon induced a rally-killing double play, yelled and glanced over his shoulder at Díaz. The Rays, in that moment, looked a few shades past frustrated. The Astros were in control.