Kyle Seager added a two-run shot, while Dustin Ackley drove in two and Justin Smoak contributed a solo blast for the Mariners, who have won four in a row.
Joe Saunders (9-8) lasted 5 1/3 innings, giving up three runs on nine hits, fanning six with three walks. Tom Wilhelmsen allowed a run and two hits, but recorded the final four outs for his 20th save.
Barnes finished 5-for-5 with a homer, two RBI and scored three times for the Astros, losers in six of their last seven. Brett Wallace slugged a two-run homer and drove in three, while Matt Dominguez knocked in two.
"I just was excited that I had the opportunity to do it and was able to achieve it," Barnes said of hitting for the cycle.
Bud Norris (6-9) was tagged in defeat for six hits and as many runs with four walks over 5 2/3 frames.
Mike Zunino and Ackley both walked to kick off the eighth, and Miller launched his second career homer, this one a three-run blast, to make it 9-3 for Seattle. The Mariners were forced to hold on in the later stages.
"I was just trying to have another good at-bat and was able to get another one," Miller said of his second homer of the night. "It was fun."
After Justin Maxwell singled to start the home half, Barnes completed his feat with a double to right, sliding in just ahead of the tag. A Dominguez groundout scored Maxwell for a five-run margin, then Wallace reached the seats in right center for a 9-6 contest. Later in the frame, Jose Altuve tripled to dead center and Jason Castro walked, before Wilhelmsen quelled the rally by inducing an inning-ending fielder's choice grounder from Chris Carter.
Smoak put the visitors into double digits with a leadoff blast in the ninth, but the Astros refused to cave. Barnes singled with two outs, took second on a defensive indifference, and scored on a single from Dominguez. Wallace, however, grounded to first to end the game.
Barnes' two-out solo homer in the home second put the Astros on the board, but the Mariners began to pull away.
Kendrys Morales began the fourth with a base hit and Seager followed with a two-run homer. Two batters later, Michael Saunders was plunked and Zunino walked ahead of Ackley's two-run double for a 4-1 advantage.
Houston got a run back in the home half as Barnes' two-out triple plated Maxwell.
It was 6-2 in the sixth when Zunino walked with one down and Miller hit a two- out, two-run shot to right for his first career home run, but the Astros responded in their turn on a bases-loaded fielder's choice grounder from Wallace.
Barnes reached in that frame with a one-out single.
Miller became the first player in Mariners history to record two games of four-or-more RBI within the first 17 appearances of his career ... The 23- year-old collected four RBI in an 11-8 loss to Boston on July 9 ... Barnes became the first Astros player to hit for the cycle since Luke Scott on July 28, 2006, and the seventh man in franchise history, following Cesar Cedeno (1972, '76), Bob Watson (1977), Andujar Cedeno (1992), Jeff Bagwell (2001) and Craig Biggio (2002) ... Seager extended his hit streak to 15 games ... The last Astro with a five-hit game was Hunter Pence, on May 27, 2008 at St. Louis ... Castro's first-inning double was his 26th this season, snapping the previous Houston record for a catcher, held by Brad Ausmus in 1997.
07/20 03:24:04 ET