The Cubs trailed 4-0 and were down to their last out when they mounted a rally, ignited when Nate Schierholtz delivered a pinch-hit, two-run double with the bases loaded off Michael Kirkman.
Rangers closer Joe Nathan entered and hit Welington Castillo with a pitch to re-load the bases.
That brought up Barney, who smacked a drive to center field that Gentry snagged with a dive to end the contest, giving Nathan his fifth save of the season.
Derek Holland (1-1) earned the win with seven shutout innings, allowing just two hits while striking out seven.
Adrian Beltre homered as Texas won for the third time in four contests.
Cubs starter Travis Wood (1-1) surrendered two runs and five hits over 7 1/3 innings.