Paul Konerko and Carlos Quentin hit back-to-back doubles in the sixth to tie it at 3 for Chicago. Two outs later, Ramirez lined a homer off starter Scott Feldman (5-8).
Mark Buehrle (7-7) won for the fourth time in five starts to even his record for the first time since April 21. He allowed three runs -- including homers by Josh Hamilton and Julio Borbon -- and five hits over seven innings to improve his career record against Texas to 12-5.
Matt Thornton, who earned his first All-Star berth, got three outs for his fifth save in seven chances. He was subbing for regular closer Bobby Jenks, who came off the bereavement list on Friday after missing almost a week and is working to get back into game shape.
The White Sox have won 18 of 23 to move a game behind Detroit and Minnesota in the AL Central.
Hamilton homered for Texas to extend his home hitting streak to 24 games, second-longest in club history. His two-run shot in the fourth after Vladimir Guerrero singled gave Texas a 2-1 lead. Hamilton had been tied at 23 straight game with Michael Young (2009) and Ivan Rodriguez (1995). Al Oliver's 30-game streak in 1981 is the Rangers' home record.
Hamilton and Guerrero were voted as starters for the AL All-Star team announced earlier Sunday.
Feldman allowed five runs -- four earned -- and eight hits in six innings for the AL West-leading Rangers, who have lost four of six.
Of Chicago's 24 hits in the first two games of the series, 22 were singles and two were doubles. This time, four of the nine hits for the White Sox went for extra bases.
Chicago got an unearned run in the second when Quentin reached on third baseman Young's throwing error, and scored on Mark Kotsay's double.
After Hamilton's 20th homer of the season sent Texas in front in the fourth, Chicago tied it at 2 in the fifth on rookie Dayan Viciedo's RBI groundout.
Borbon's one-out solo homer in the fifth put Texas back ahead 3-2.
Chicago third baseman Omar Vizquel left in the third inning after being hit by a pitch from Feldman. He was struck by a fastball in the left knee and rolled to the ground in pain with what was later diagnosed as a bruise following negative X-rays.
He was examined on the field by White Sox medical personnel before walking slowly to the dugout and was replaced by Viciedo. The White Sox said Vizquel would be evaluated Monday in Chicago.
NOTES: The Rangers played their 81st game, reaching the midway point of the season at 48-33, their second-best record in club history at that point. The 1996 team was 49-32. ... The White Sox completed a 3-3 trip with their 80th game. ... Rangers rookie 1B Justin Smoak went 0 for 3 and is hitless in his last 23 at-bats. ... Ramirez was 8 for 12 in the three-game series.