Updated

Just when it seemed like Texas left-hander Cole Hamels was starting to struggle Friday night he flipped a switch.

After that it was all over for the Baltimore Orioles. Hamels had his best performance since being acquired from Philadelphia last month as the Rangers opened a key series with a 4-1 victory.

The win moved the Rangers four back of Houston in the American League West and kept them in possession of the second wild-card spot.

And Hamels was the difference maker as he pitched eight innings, allowing just two hits and striking out 10.

"Being able to go deep in the ballgame and hopefully giving the bullpen a break, and being able to limit the runs is what I like to do," Hamels said. "I'm here to be able to do that. When you're able to do that, you're able to win a ballgame. We got huge contributions with the hits and that's how you win."

A wild Hamels walked in a run in a third inning in which he walked. But instead of losing a grip with the bases loaded and Baltimore up 1-0, Hamels went another route and became unhittable.

Hamels ended the third by retiring Matt Wieters on a grounder to short. That was the start of a string of 14 straight retired by Hamels. He followed the three-walk third by striking out the side in the fourth.

By the time the Hamels streak came to an end with a one-out walk to Manny Machado in the eighth inning, the Rangers offense had followed the Hamels heat and gone on a hot streak of its own.

Shin-Soo Choo tied the game with a solo homer to right in the fifth and then Chris Gimenez put the Rangers up for good with a solo homer in the fifth inning. The Ranger added another run in that frame on a fielder's choice from Choo. More unnecessary insurance came in the seventh on an RBI triple by Delino DeShields.

The third inning took its toll on Hamels, as he was at 56 pitches after his 30-pitch frame. But his last pitch of the eighth, which resulted in a double-play ground ball, was his 111th of the night. He finished with his 30th career game of at least 10 strikeouts.

The only two hits Hamels allowed came on a bloop single to left by Wieters in the second and a one out double by Paul Janish in the third. The way he pitched in the third wasn't acceptable to Hamels.

"Giving away free passes, I know you're playing against a very good ballclub, at the same time you want to make guys earn their hits and their bases, especially the runs," he said. "The way I go out there I like to challenge guys and not give guys the free pass. If the guy hits them it, it's easier to accept. Once you're doing that you then have to kick it in gear and focus a little more because that's not the gameplan or the way I want to pitch."

Manager Jeff Banister had no doubt Hamels would be able to recover from the walks.

"What got him back on track was himself really," Banister said. "The veteran pitcher in him and I know the third is not what he wanted to do. It got away from him a little bit. I think the last out of the inning (to Wieters) is what got him on track."

While it's taken Hamels a little while to find his footing, that's not the case for Gimenez. His game-winning homer was his fourth in the last 11 games. The Gimenez homer to center bounced off a camera man, which Gimenez apologized for.

He's not apologizing for production that has him hitting .286 with 10 RBI.

"I don't care where it goes as long as it goes over," Gimenez said. "I've been doing a little work on my swing and it's kind of being able to repeat it consistency. It's about locking in a pitch and not missing it. Thankfully right now I'm locking on a pitch and not missing it."

MORE FROM FOX SPORTS SOUTHWEST:

- PHOTOS: Cowboys Cheerleaders Auditions

- Preseason predictions for 2015 MLB season

- Ranking NFL quarterback salaries

- Oldest player on every NBA team

- College football's highest paid coaches in 2014

- Highest paid player on every MLB roster