David Beckham helped set up both scores for Los Angeles (18-3-10), which remained MLS's only team unbeaten at home - improving to 11-0-5.
''They're not going to be in any highlights,'' said Galaxy coach Bruce Arena of the auspicious goals. ''But they went over the line. Both count.''
Barrett tied the score in the 59th minute following a pass into the box by Beckham, who got his league-best 15th assist. The Galaxy then went ahead in the 72nd minute courtesy of an own-goal on a sequence started by the English star's free kick.
''If I play balls into the right area, we've got guys who can get into the right spot and score,'' Beckham said. ''I honestly enjoy the assists more than scoring.''
The win puts the Galaxy seven points clear of Seattle in the race for the Supporters' Shield. The Sounders' 2-1 win over New England earlier prevented the Galaxy from wrapping up the award.
Fabian Espindola scored in the 45th minute for Real Salt Lake (15-10-6), which lost its third straight.
Salt Lake had a season-high five-game winning streak to open September before struggling. Since a 3-1 win at New York, the club has been outscored 9-2 in the three losses.
''I think we stretched L.A. to their wits end,'' Salt Lake coach Jason Kreis said. ''They're the best team in the league for a reason. We need to try and draw from this game.''
Things were looking up for the away team when they grabbed the 1-0 lead moments before halftime.
Midfielder Javier Morales, making his first start and second appearance since suffering a fractured ankle on May 7, played in a corner kick that Espindola flicked off the side of his head. It tied him for the team-lead with 10 goals.
The Galaxy, who had lost both previous games in which they trailed at halftime, regrouped at the break and controlled play over the final 45 minutes.
The tying goal came after Beckham played a long ball that had Barrett and Salt Lake defender Jamison Olave jockeying for position near the front post. The bouncing ball hit off both players' thighs before Barrett managed to get enough of his left foot on it from a tight angle near the sideline to glide it over the line.
It was Barrett's second goal in two games and sixth of the season.
''I don't know how it went in. I have no idea,'' Beckham said. ''I just know it was another assist for me.''
Salt Lake's failure to clear the ball from its own end resulted in the go-ahead tally. Beckham's cross was headed by Landon Donovan to Mike Magee. His shot deflected first off Chris Wingert and was then knocked into the goal by captain Nat Borchers.
''They weren't the prettiest of goals,'' Arena said. ''We were gritty and kept our composure. We did what we need to do.''