Martinez (2-8), who won for the first time since May 24, may have seemed like an unlikely winner based on his record and ERA. But he got the job done and more importantly for the Rangers they avoided a series sweep, and ended the Astros' seven-game winning streak against them.
"That's what he's up here for, to win ballgames, and if we didn't have a tremendous feeling about the kid, he wouldn't be up here," Rangers manager Ron Washington said. "[He was] 1-8, five-something ERA. We believe in him. We'll give him all the opportunity we can to get him to improve.
"He wants to be better. The kid is just out of [Class] A ball trying to get big league hitters out. He'll figure it out."
The Rangers received home runs from Adrian Beltre and Shin-Soo Choo leading off the sixth and seventh innings respectively to close out the scoring.
The Rangers had lost 36 of 46 games and nine of 11 on the road. On Saturday the Astros beat Darvish, 8-3.
Martinez, who came into the game with a 5.31 ERA, needed 102 pitches to get through five innings. He allowed single runs in the first and third innings as Houston built a 2-0 lead. But Martinez did not allow a run in his last two innings and the offense got untracked against Dallas Keuchel, who did not allow a hit in his first three innings.
"When we tied the game up it was important to have a shutdown inning and get those guys back in and continue that hot streak," said Martinez, who allowed five hits with six strikeouts and two walks.
Texas tied the game with two runs in the fourth and took a 4-2 lead with two runs in the fifth.
In the fourth, Alex Rios doubled in Elvis Andrus, and Rios used some aggressive baserunning to score from second on an infield hit. But Rios aggravated his sprained right ankle sliding into home and left the game.
Rios will be re-evaluated on Monday in Arlington when the Rangers open a seven-game homestand. Both Washington and Rios said the outfielder is expected to play Monday against Tampa Bay. Rios was replaced in the bottom of the fourth by Jim Adduci, who on Saturday hit his first Major League home run.
In the Rangers' fifth, Robinson Chirinos, who led off with a double, scored on a Keuchel wild pitch for a 5-2 lead. Daniel Robertson scored on a sacrifice fly from Elvis Andrus.
The Rangers caught a break in the fifth inning on a ground-rule double by All-Star second baseman Jose Altuve, who reached base three times against Martinez -- two hits, a hit by pitch. In a 4-2 game, with one out and Marwin Gonzalez on first base, Altuve's double to right field would have scored Gonzalez, but he had to go back to third base.
Martinez then struck out Chris Carter and Jason Castro to end the inning -- his final two batters.
"I don't blow anybody by," said Martinez. "I'm not one of those guys that can throw in the upper 90s. I really have to locate. If I can make hitters feel uncomfortable by pitching up in the zone, then I think that will work to my strengths."
"Today was a good sample of a kid being aggressive and executing," Andrus said.
After Martinez's departure, Roman Mendez threw a scoreless sixth, Shawn Tolleson threw two scoreless innings and Neftali Feliz pitched a scoreless ninth inning.
Beltre had two of the Rangers' eight hits. He is batting .375 (51-for-136) with 11 home runs and 30 RBIs against Houston since 2012, and has hit safely in his last 11 games versus the Astros. Beltre's 17th home run to left field was measured at 374 feet.
With his 11th homer of the season, Choo has hit safely in his last six games. On Saturday, Choo collected his 1,000th Major League hit.
Keuchel (10-8), who started so strong, gave up five runs and six hits in six innings. The left-hander struck out four and walked three. He gave up Beltre's homer. Jose Veras, who relieved Keuchel to start the seventh, gave up the homer to Choo.
The Rangers didn't get their first hit off Keuchel until Andrus led off the fourth inning with a single.
"You can't be on your game all the time, but I thought the first three innings I was about as good as I've been this season," Keuchel said. "It's very frustrating. We'll come back and be better."