Miller, who started the season in Double-A, launched a two-run shot to the second deck in right field to chase starter Bud Norris (6-9) and make it 6-2 in the sixth. He finished with three hits and added a three-run homer when he sent one to the first row in right field in the eighth.
Kyle Seager extended his major league-best hitting streak to 15 games with a two-run homer that gave Seattle a 2-1 lead in the second, and Justin Smoak hit a solo home run in the ninth.
Barnes hit a solo homer in the second inning and had a run-scoring triple in the fourth. He singled in the sixth inning and completed the cycle with a sharp groundball double down the right field line in the eighth inning.
He added a single in the ninth to finish 5 for 5 and become the first Astro to collect five hits since Hunter Pence did it in May 2008.
It was Seattle's 23rd straight game with at least one homer to extend the team record. It is tied for the sixth-longest such streak in major league history dating to 1916.
Mariners starter Joe Saunders (9-8) yielded nine hits and three runs with six strikeouts in 5 1-3 innings for his fourth straight win. Tom Wilhelmsen allowed two hits and a run in 1 1-3 innings for his 20th save.
Norris had a second straight tough start, allowing six hits and six runs with four walks in 5 2-3 innings. He has allowed 17 hits and 13 runs in his last two starts.
Miller's dazzling play wasn't limited to offense on Friday night. He also had a nice night on defense, starting a nifty double play in the fourth inning by flipping a grounder hit by J.D. Martinez to second baseman Nick Franklin. Franklin barehanded the ball and threw it to first to complete the double play.
Barnes became the second player this season to hit for the cycle against the Mariners. Mike Trout of the Angels did it on May 21.
It is the eighth time an Astro has hit for the cycle and the first time since Luke Scott did it on May 28, 2006, against Arizona.
Barnes is the first right-handed hitter to accomplish the feat since Craig Biggio did it on April 8, 2002, at Colorado. Barnes pumped his fist after he beat the throw into second base on his double.
Saunders walked Justin Maxwell with one out in the sixth before a single by Barnes. He was replaced by Yoervis Medina after Matt Dominguez drew a walk to load the bases.
Pinch hitter Brett Wallace grounded into a force out that scored a run to cut the lead to 6-3.
Wallace added a two-run homer in Houston's three-run eighth inning.
Kendrys Morales singled to start the fourth inning. Seager gave Seattle a 2-1 lead with his shot to left field. Norris plunked Michael Saunders with one out before walking Mike Zunino. Dustin Ackley followed with a double that rolled into the left-field corner to score two and push the lead to 4-1.
Houston's Jason Castro hit his 26th double of the season in the first inning to pass Brad Ausmus for most doubles by a catcher in team history. Ausmus had 25 in 1997.
NOTES: The series continues Saturday when Seattle's Hisashi Iwakuma (8-4) opposes Erik Bedard (3-6). ... Houston will recall RHP Jarred Cosart from Triple-A Oklahoma City on Tuesday to start against Oakland. The 23-year-old took a no-hitter into the seventh inning and got the win, allowing just two hits and no runs in eight-plus innings in his major league debut just before the break. He was optioned to Oklahoma City after the game, but is scheduled to stay this time and be Houston's fifth starter.