Hamels won because he was able to grind through 6 2/3 innings. He allowed five hits, walked three and hit a career-high three batters but allowed just one run, on a Tyler White home run.
Hamels also won because his defense turned three completely different double plays in crucial situations, and he won because of the late-inning relief work of Sam Dyson, Jake Diekman and Shawn Tolleson.
The Rangers made a lot of winning plays to pull this one out, between the double plays, left fielder Ian Desmond cutting down Jose Altuve trying to turn a single into a double and the pitchers holding the Astros to 1-for-12 in runners in scoring position.
"That was a great win for us," Dyson said.
"Any win is a good win, but especially when you can win a close one like that," Tolleson said. "We made a lot of big plays and got big outs in crucial moments of the game."
This one wasn't over until Tolleson, with the potential tying run on first, retired Altuve on a line drive to right to end the game. But there was intensity from the beginning, as Hamels hit both Altuve and George Springer to start the game. Hamels then struck out Carlos Correa and White, with the second K turning into an inning-ending double play when catcher Bryan Holaday threw out Springer trying to steal.
Rasmus didn't try to score as Mazara made a strong throw to Holaday at the plate, but Gomez bolted too far off first base, and second baseman Rougned Odor got in behind him. Holaday threw to Odor, who chased Gomez to second before firing back to Holaday as Rasmus broke for the plate. Rasmus was tagged out to complete the double play.
"It was pretty easy," Holaday said. "Nomar made a good throw, I saw Gomez take off and I let Odor handle it."
"You start off with Holaday, he can't leave the plate," manager Jeff Banister said. "He held his ground, made a good throw and Odor stayed under control. We got in a situation where there was a jail break, but more than anything else, our guys showed the presence of mind to stay calm and under control."
Hamels retired Jason Castro to end the inning. After Odor's home run in the bottom of the frame gave the Rangers a two-run lead, Altuve led off the third with a single to left but was cut down by Desmond at second as Odor made a diving tag.
"That was an inning-changing throw by Desmond," Hamels said.
"How about the tag by Odor -- that was a great play right there," Desmond said.
Hamels, with the Rangers turning a 5-4-3 double play in the sixth, was able to take a one-run lead into the seventh before leaving with runners at the corners with two outs. Dyson came in and got Springer on a grounder back to the mound.
Dyson gave up a leadoff double to Correa in the eighth but retired White on a grounder to third. Diekman came in to strike out Rasmus and Gattis to end the inning.
"Those guys have been great all year," Tolleson said. "Tonight was another example of them shutting the door in crucial moments."
It was part of a night of winning baseball.
T.R. Sullivan is a reporter for MLB.com. Follow him on Twitter @Sullivan_Ranger and listen to his podcast. This story was not subject to the approval of Major League Baseball or its clubs.