Escobar, who also tied a season high with three RBIs, advanced to third on a long fly ball off the bat of Desmond Jennings and scored an insurance run on a wild pitch.
Jamey Wright (2-1) got the win against his former club with an inning of relief. He struck out two and gave up one hit. Fernando Rodney worked the bottom of the 11th to pick up his 18th save of the season.
"How about the job [Kyle} Farnsworth and Jamey Wright did to get us to that particular moment?" Rays manager Joe Maddon said. "We got them into some high-leverage moments, and they responded well, which should even further their value as we move it down the road."
For the third consecutive game, Jennings led off with a hit. He was more patient at the plate Thursday, however. After hitting the first pitch of the game for singles in the last two games, Jennings took a pitch to open Thursday's game and then blasted a long double off the bullpen in left-center field -- narrowly missing a homer.
As in his last two outings, Jennings scored the first game's first run. He was moved to third on a single by Matt Joyce and then scored on a slow roller off the bat of Evan Longoria.
And as they did Wednesday, the Astros went to the longball to tie the game. They did so twice, both times by Houston third baseman Brett Wallace, who opened the fourth inning with an opposite-field shot that just cleared the left-field fence and tied the game at 1; then popped a three-run homer in the eighth inning just past the reach of Rays right fielder Wil Myers and a couple of rows into the right-field seats to knot it at 5.
"Emotional rollercoaster," Houston manager Bo Porter said. "To give up the three [in the eighth] and then fall behind, and Wally hit the three-run homer, you really wanted to build off that momentum and end it right there. The boys battled, and it was a really good baseball game."
Wallace's first homer was Houston's first hit of the game and came on the 46th pitch from Rays starter Chris Archer. Coming into the game, opponents were hitting just .212 against Archer over his first 45 pitches of a game this season. After 45 pitches, they were hitting .300.
"Wallace is hot right now," Archer said. "I felt like I made a good pitch. He put a good swing on a good pitch, hit it where it was pitched. I definitely didn't try to change things after giving up a solo home run."
Archer went six innings. He allowed just two hits, the fewest since a two-hit, seven-inning outing June 7 in a win over Baltimore. Archer on Thursday issued three walks, the first allowed in 25 innings by the Rays staff. Archer struck out five and was effective with his 97 pitches, throwing 62 for strikes.
"I'd say that I'm continuing to progress," Archer said. "I felt comfortable with all three pitches today. I haven't felt that the whole time I've been here. Some nights it's one; some nights it's two. Today, it was all three. I felt like all things were clicking. The defense was making outstanding plays. We scored runs in a timely fashion."
Houston took a 2-1 lead in the fifth inning. Jimmy Paredes followed a Brandon Barnes single with a walk. The two moved up on a double steal, and Barnes scored on a sacrifice fly from Jake Elmore.
The Rays tied it in the seventh. Escobar, who reached on a fielder's choice, moved to third on a double by Jennings and scored on a wild pitch.
They scored three more times in the eighth on a two-run double by Escobar following a bases-loaded fielder's choice groundout from Lobaton that scored Sam Fuld with the go-ahead run. Fuld was running for Longoria, who opened the inning with a walk.
Myers lined a double down the right-field line, and after working a 3-0 count, Kelly Johnson was intentionally walked to load the bases before Escobar chased Astros center fielder Brandon Barnes up Tal's Hill. Barnes stumbled up the slope but had little chance to catch Escobar's blast.
But Joel Peralta could not hold the lead out of the bullpen. After issuing a walk and yielding a single, Peralta served up the tying home run pitch to Wallace. It was Wallace's second career multihomer game and the sixth this season by the Astros.
Farnsworth came on to pitch, and Escobar helped put out the fire by ranging deep in the hole at short to glove what looked like a sure single off the bat of Astros DH J.D. Martinez.
Escobar, in what is becoming routine defense on his part, wheeled and fired to Ben Zobrist at second base, who in turn fired to first to complete the double play.
"You don't see that play anywhere else in baseball," Maddon said. "He had himself a heck of a day.
"This guy is definitely an All-Star-caliber player and absolutely a Gold Glove-caliber player. As he continues to hit, more people will take notice; that's just the way this game works. If he keeps it up, which I believe he will, he's going to get more attention."
James Loney extended his hitting streak to 15 games, tying a career high, with a one-out single in the fourth inning. Loney entered the game leading the Majors in road batting average (.371).
The Rays improved to 5-11 all-time on Independence Day, and it was their first win on July 4 since 2010 at Minnesota.
"Overall, today's game was kind of like the definition of the Rays," Archer said. "We pitched pretty well, we scored runs when we needed to and we played defense all night."