USA TODAY Sports

The Texas Rangers used an error and a wild pitch to score the go-ahead run in the top of the seventh to beat the Houston Astros 4-3 on Tuesday night at Minute Maid Park.

The Rangers (59-76) snapped their nine-game losing streak and beat one of the Astros’ top pitchers, Framber Valdez (14-5), in the process.

Unlike Monday night, when the Rangers fell behind 1-0 in the second inning and never scored, they put up three runs in the top of the second against Valdez. Texas lost to the lead, but it was the seventh inning that did in the starter and Houston.

With the game tied 3-3, two mistakes — including one of Valdez’s own doing — helped the Rangers to the lead.

Rangers shortstop Corey Seager reached first on a one-out error by first baseman Yuli Gurriel, who mishandled the ball while trying to get it to Valdez, who was covering first.

Nathaniel Lowe singled to move Seager to second. Adolis García moved Seager to third on a weak fielder’s choice grounder to catcher Martin Maldonado. He threw Lowe out at second.

Mark Mathias then drew a walk, but Valdez’s final pitch went into the dirt and flew past Maldonado, allowing Seager to score and give the Rangers the lead. That led to Valdez’s exit from the game.

While Phil Maton got the Astros (87-49) out of the inning, Valdez was on the hook for the loss, despite striking out 11 and giving up just six hits in 6 2/3 innings. He walked four and gave up four runs, but two were earned.

The Astros put the tying run on base in the bottom of the ninth against Rangers reliever Jose Leclerc. He walked Jose Altuve with one out. Altuve stole second on a 1-1 pitch with Jeremy Peña at the plate. Leclerc buckled down to get the last two outs.

Earlier in the game, the Rangers scored three off Valdez in the second. Mathias walked to lead off, followed by a Leody Taveras singled and an Ezequiel Duran double, which scored both for a 2-0 lead.

Texas catcher Sam Huff — starting for the first time since his call-up from Triple-A Round Rock on Monday — hit an infield single to move Duran to third. Astros second baseman Jose Altuve made a bad throw, one that bounced toward first base and away from Gurriel. The ball rolled into the Astros dugout and Duran scored easily to make it 3-0.

Valdez retired the next three hitters to get out of the jam.

That staked Rangers starter Glenn Otto to a three-run lead. By the time he left the game after four innings, he had given it up, despite giving up only five hits and three runs (two earned). He struck out five and walked one.

Kyle Tucker was a problem for the Rangers. The Astros outfield singled to lead off the bottom of the second. He advanced to second on a passed ball, stole third before and scored on Gurriel’s RBI ground out.

Altuve homered in the bottom of the third to cut the Texas lead to 3-2. In the bottom of the fourth, Tucker singled to lead off the inning. He later stole second, moved to third on an infield single by J.J. Matijevic and scored on Chas McCormick’s fielder’s choice groundout to Seager.

Once Otto left the game, the Rangers bullpen threw five innings of scoreless relief, with Taylor Hearn going two innings and claiming the victory. Jesus Tinoco and Matt Moore worked a combined two innings, while Jose Leclerc worked the ninth for the save.

The Rangers announced they are preparing a couple of players for rehab assignments at Triple-A Round Rock — outfielder Eli White and pitcher Spencer Howard.

The Rangers will activate rookie Cole Ragans from the injured list on Wednesday to start the series finale at 7:10 p.m.

You can find Matthew Postins on Twitter @PostinsPostcard

Catch up with Inside the Rangers on Facebook and Twitter.

More must-reads:

TODAY'S BEST
Watch: Jamal Murray beats the Lakers again to win series
Watch: Jalen Williams takes over late to complete sweep for Thunder
Derrick White shines to give Celtics 3-1 series lead vs. Heat
Panthers advance by eliminating Florida rival Lightning
Stars tie series with another road win over Golden Knights
Travis Kelce inks record-setting contract extension with Chiefs
Timberwolves get brutal update on head coach's injury
Rich Paul details Suns' 'catastrophe' following their playoff elimination
Broncos GM explains why Bo Nix is more 'game-ready' than younger QBs
Insider says Giants’ interest in drafting a QB was a smokescreen
Week 11 NASCAR power rankings: Cup Series leader races to the top
LIV Golf continues to build momentum with record-setting week in Adelaide
MLB rankings: The five most disappointing free-agent signings
Five undrafted rookie free agents who should make a 53-man NFL roster
Brewers burned by controversial ninth-inning call vs. Rays
After landing marquee transfer, UConn HC has chance at three-peat
New Michigan HC Dusty May secures another impact transfer
Dodgers veteran reliever placed on injured list
Report: Celtics star might have dodged catastrophic injury
Report sheds light on Bengals, Tee Higgins contract talks