Barnes, who went 2-for-4, brought in two runs with a double in the second inning and then scored in the fourth on a double-play ball by Jonathan Villar.
Jason Castro and Chris Carter drove in a run apiece for the Astros, who ended a six-game losing streak. Jordan Lyles notched the win on a run off five hits in seven innings.
Oakland remained a game behind the Texas Rangers in the AL West.
Bartolo Colon (14-5) lost his second consecutive start. The veteran Colon allowed five runs on seven hits over just four innings. Yoenis Cespedes had a two-run homer and went 3-for-4 at the plate.