Pérez (9-3) tied a season high by allowing seven runs in five-plus innings to snap a nine-game winning streak, the longest active string in the majors and the best of his career. He had gone 19 straight starts without a loss, with his last one coming on April 17.
The Astros snapped a two-game skid playing without manager Dusty Baker who remained out after testing positive for COVID-19 Thursday. Baker isolated in a Cleveland hotel room all weekend before taking a private jet back to Houston on Monday.
Bench coach Joe Espada is managing the AL West leaders until Baker returns.
Jose Urquidy (11-4) yielded five runs with a season-high three home runs in five innings but got his third straight win thanks to his offense.
"He grinded. He competed," Espada said. "He gave us five innings, five good innings. Anytime you keep us in the game, you keep this offense in the game, we're in striking distance and that's what Urquidy did."
"He's been very valuable since the first day he got here," Espada said. "He's one of those players that sometimes goes unnoticed because he's not your everyday guy ... but he's been a very special player for us. He contributes in so many different ways."
The Rangers quickly broke the tie on a solo shot by Adolis García with one out in the fifth inning that made it 5-4.
Jose Altuve, who had two hits, doubled home Jake Meyers from first in the bottom half to tie it. Altuve stole third base, and the Astros took their first lead of the game when he scored on a sacrifice fly by Yuli Gurriel that made it 6-5.
Semien hit a leadoff homer to put the Rangers up 1-0. He drew a walk to start the third before Seager's shot to the bullpen in right center extended the lead to 3-0.
Urquidy plunked Josh Smith with no outs in the fourth and he stole second base. A single by Thompson sent him home to make it 4-0.
Pérez sailed through the first three innings before getting into trouble in the fourth because of walks.
"You can't give them free passes," Texas manager Chris Woodward said. "If you make mistakes on defense or you give them free passes, they make you pay. That's one thing they're really, really good at."
Altuve led off with a single and Pérez walked Gurriel. After Yordan Alvarez grounded into a double play, Pérez issued consecutive walks to Bregman and Tucker to load the bases.
Díaz then hit a changeup over the center field wall for his second grand slam this season to tie it at 4-all.
He said there was no panic when they fell behind big early.
"We know what we are capable of doing and it's a long game," he said. "So we just keep pushing. We just keep fighting."
Astros: Espada said they haven't yet decided the next step for RHP Lance McCullers Jr. after he made his fourth rehabilitation start at Triple-A Sugar Land on Sunday. McCullers has been out all season with a strained right forearm. ... Espada said he's been in constant contact with Baker since his positive test and that he's doing well and itching to rejoin the team, but it's unclear when that will be.
At 71-40 the Astros have matched the best 111-game record in franchise history. They also won 71 of their first 111 games in 2017 and 2019.