Troy Taormina-USA TODAY Sports

Aledmys Diaz drilled a grand slam with two outs in the fourth inning to spark a rally from a four-run deficit as the Houston Astros topped the visiting Texas Rangers 7-5 on Tuesday.

Diaz pulled the Astros even with his 10th home run and second grand slam this season, following consecutive two-out walks issued by Rangers left-hander Martin Perez (9-3).

Jose Altuve opened the fourth with a single and Yuli Gurriel followed with a walk, but Perez appeared to clear danger when he induced a double-play grounder off the bat of slugger Yordan Alvarez.

But Perez, who retired the first nine batters he faced, failed to regain his footing. He walked Alex Bregman and Kyle Tucker before Diaz blasted an 0-1 changeup 432 feet to left-center field.

In the fifth, Altuve doubled home Jake Meyers and scored on Gurriel's sacrifice fly for a 6-5 lead. In the sixth, Tucker chased Perez with a double off the scoreboard in left, scoring Bregman.

Perez suffered his first loss since April 17, a span of 19 starts. He had dominated the Astros in two starts this season, including a shutout on May 20. On Tuesday, he surrendered seven runs on six hits and three walks, with two strikeouts, over five-plus innings.

It didn't take long for Astros right-hander Jose Urquidy (11-4) to see his streak of nine consecutive quality starts come to an end. Marcus Semien clubbed his 16th home run leading off the game. It was the first of three home runs surrendered by Urquidy, who allowed two additional baserunners in the top of the first.

Semien walked leading off the third and scored when Corey Seager smacked his 25th home run, a two-run shot to right-center that extended the Rangers' lead to 3-0.

Texas pushed that advantage to 4-0 in the fourth when Bubba Thompson delivered an RBI single that scored Josh Smith. Adolis Garcia socked his 19th homer with one out in the fifth to put Texas ahead 5-4.

However, the Astros' two-run rally in the bottom of the fifth made a winner of Urquidy, who surrendered five runs on five hits and two walks, with four strikeouts, over five innings.

Texas has dropped nine of 12 games to Houston this season.

More must-reads:

TODAY'S BEST
Prolific former Brewers, A's slugger announces retirement
Watch: Padres star passes father on all-time home runs list
Saints to sign veteran offensive lineman
Smother's Day: Pacers shut down Knicks in first half of Game 4
Pistons make wrong kind of history at NBA Draft Lottery
Watch: Pacers C Myles Turner makes absurd three-pointer in first quarter vs. Knicks
Hawks win 2024 NBA Draft Lottery
Giants place key outfielder on injured list
Broncos release former Super Bowl champion WR
Novak Djokovic thinks water bottle incident may have played role in surprising loss
Steelers agree to deal with veteran CB
Bruins captain out for Game 4 vs. Panthers
Veteran WR announces retirement from NFL
Mavericks come from behind to down Thunder, take 2-1 series lead
Stars continue road dominance with Game 3 win over Avalanche
Watch: Paul Skenes wastes no time showing why Pirates drafted him No. 1 overall
Watch: Braves were one out away from first no-hitter in 30 years
Roman Wilson hopes to become Steelers' next 'great' WR
Chargers sign veteran edge-rusher
Justin Allgaier dominates at Darlington for first win of 2024

Want more sports news?

Join the hundreds of thousands of fans who start their day with Yardbarker's Morning Bark, the best newsletter in sports.