The Dodgers had the bases loaded with one out when Barnes hit a chopper to Texas reliever Matt Bush, whose toss toward the plate was wide as Hernandez came home. Bush was charged with an error on the play.
Adam Liberatore (2-1) pitched a scoreless inning for the victory as the Dodgers' bullpen delivered six scoreless frames. Former Dodger Jesse Chavez (2-1) took the loss, giving up an unearned run on a hit and three walks over 2 1/3 innings.
Barnes had struck out three times and hit into a double play in the ninth inning with the winning run at third base before bringing home the game-winner. The Dodgers won for the ninth time in their 11 games in June and are 19-6 since May 17.
The Rangers lost their sixth consecutive game and have dropped nine of their last 12.
The Dodgers' Matt Kemp and the Rangers' Robinson Chirinos both were ejected after a scuffle at the end of the third inning. While trying to score on a Hernandez single, Kemp bowled over Chirinos, and a shoving match ensued that cleared both benches.
The Dodgers took a first-inning lead on a Justin Turner home run, just his second on the season. Turner started the season on the disabled list due to a fractured wrist.
It was the 30th home run in 11 June games for the Dodgers, the most in baseball this month.
The Dodgers made it 2-0 in the second inning when Yasiel Puig stole third and scored when Chirinos' throw got past third baseman Adrian Beltre.
The Rangers got even immediately after the scuffle between Kemp and Chirinos. Jurickson Profar cut the Dodgers' lead to a run with a fourth-inning RBI single that scored Beltre just ahead of the throw from Hernandez in center field.
The next batter, Joey Gallo, tied the score with a single that scored Profar.
Shin-Soo Choo reached base four times on a hit and three walks, extending his career-best on-base streak to 28 games. He had three hits Tuesday.
Beltre, a former Dodger, had three hits and was 5-for-7 in the brief two-game series. He finished the night with 3,092 career hits, breaking a tie with Ichiro Suzuki (3,089) for the most hits by a foreign-born player.
Rangers starter Cole Hamels gave up two runs (one earned) on five hits over six innings, leaving after throwing 96 pitches. He had six strikeouts with four walks.
Dodgers starter Kenta Maeda gave up two runs on five hits over five innings in his first start since coming off the disabled list. He had been sidelined due to a strained right hip. Maeda walked three and struck out just one after striking out a combined 20 in the last two full starts before he was injured.
--Field Level Media