SEATTLE -- Mike Trout scored the go-ahead run on an error in the top of the ninth inning as the Los Angeles Angels rallied from a four-run deficit to defeat the Seattle Mariners 6-5 on Friday night at Safeco Field.

The Angels (59-58) won their fourth game in a row and are one-half game out of the American League's second and final wild-card berth.

Keynan Middleton (3-0) got the victory with a scoreless inning of relief and Yusmeiro Petit pitched a perfect ninth for his second save of the season.

With one out in the top of the ninth, Trout walked against Seattle left-hander James Pazos (3-4). Albert Pujols singled to center, his third hit of the night, with Trout stopping at second.

C.J. Cron then hit a hard grounder to shortstop that Jean Segura tried to turn into an inning-ending double play. But the ball bounced off Segura's glove and into left field, with Trout scoring the deciding run.

Seattle's Nelson Cruz continued his torrid streak, going 3-for-4 with two doubles, a home run and two RBIs. Cruz homered for the fourth time in his past three games, the sixth time in six games and for the eighth time in 11 games.

The Mariners used a pitching-staff-by-committee approach because of their injury-riddled starting staff.

Left-hander Marco Gonzales, making his second start since being acquired July 21 from St. Louis, went the first 4 1/3 innings, giving up one run on four hits.

Gonzales was relieved after allowing one-out singles to Martin Maldonado and Cliff Pennington, the Nos. 8-9 batters in the Angels order.

Right-hander Emilio Pagan came on and got Cameron Maybin and Trout to fly out to end the inning.

Trailing 5-1, the Angels tied it in the top of the seventh, all four runs scoring with two outs off Mariners rookie right-hander Andrew Moore, who was making his first career relief appearance.

With one out, Martin Maldonado singled. An out later, Maybin reached on an infield single to bring up Trout, who walked to load the bases.

Pujols hit a two-run single to right field, making it 5-3. Cron grounded a run-scoring single to left and Andrelton Simmons doubled down the left-field line to tie the score at 5-5 and end Moore's night. Moore allowed four runs on six hits in 1 2/3 innings.

The Angels opened the scoring with two outs in the second as Jefry Marte, called up the previous day from Triple-A Salt Lake, lined a home run just over the wall in the left-field corner. It was Marte's fourth home run of the season.

The Mariners tied it in the bottom of the inning as Cruz led off by crushing a 3-0 pitch from Ricky Nolasco 425 feet over the wall in straightaway center field. It was Cruz's 28th homer of the season.

Seattle took the lead in the fifth as Jarrod Dyson lined a leadoff single to center field and Mike Zunino hit a 450-foot blast midway up the second deck in left field on a 2-1 pitch. The two-run shot, Zunino's 17th of the season, made it 3-1.

Robinson Cano opened the sixth with a double down the right-field line and Cruz, despite fouling a ball off his left instep that brought trainer Rick Griffin and manager Scott Servais out of the dugout to check on him, lined a run-scoring double off the right-field wall to increase the lead to 4-1.

Two outs later, Dyson hit a soft liner into left field to score Cruz and make it 5-1.

Nolasco, who pitched a three-hit shutout against the Mariners on July 1, went five innings, allowing five runs on seven hits. He walked one and struck out three.

NOTES: Mariners LHP James Paxton was placed on the 10-day disabled list with a strained left pectoral muscle. RHP Andrew Moore was recalled from Triple-A Tacoma to take Paxton's spot on the roster. ... The Mariners will retire batting coach Edgar Martinez's No. 11 jersey before Saturday's game. ... Angels RHP JC Ramirez (10-10, 4.21 ERA) is scheduled to take on Mariners RHP Erasmo Ramirez (4-4, 5.10) on Saturday in the third game of the four-game series. ... Angels LHP Andrew Heaney, recovering from Tommy John surgery in July 2016, is slated to make a rehab start Saturday for Triple-A Salt Lake.