MIAMI (AP) — Mike Stanton hit a one-out solo homer in the 10th inning Wednesday night, and the Florida Marlins overcame an early four-run deficit to avert a series sweep by beating the Philadelphia Phillies 7-6.

Stanton hit a 2-1 pitch from Danys Baez (2-4) into the seats in left. The young slugger had been hitless in his previous four at-bats, striking out twice and grounding into a bases-loaded double play.

READ MORE: Several People Injured After Tree Falls During West Philadelphia High School Reunion Party At Fairmount Park

Stanton, who has been dealing with blurry vision in his right eye because of an infection, saw a doctor before the game and was told the problem should clear up with the help of drops. The home run was his 17th this season, and the first walkoff homer of his career.

Philadelphia’s John Mayberry Jr. hit two home runs in the No. 8 spot in the order, and Jimmy Rollins also homered for the Phillies.

The Marlins rallied from a 4-0 deficit and won for only the second time in their past 17 games decided by one run. They ended a streak of seven consecutive losses to the Phillies, who lost for only the fifth time in 26 games at Miami since September 2008.

A baserunning mistake by Domonic Brown cost Philadelphia a run in the sixth. He tripled to lead off the inning, but the Marlins appealed and he was ruled out for failing to touch second base. Mayberry followed with a homer off Mike Dunn.

The Phillies stranded two runners in the ninth, and Ryan Howard hit a 400-foot flyout to center in the 10th. But the Marlins’ bullpen held Philadelphia without a hit over the final 4 2-3 innings.

Edward Mujica (6-2) pitched a perfect 10th.

Florida’s Logan Morrison hit a two-run homer, his 12th, while Hanley Ramirez had three hits and two RBIs, and Omar Infante added a triple and two singles.

Anibal Sanchez of Florida failed for the second straight start to make it to the fifth inning. He was lifted for a pinch-hitter in the fourth trailing 5-3.

Philadelphia starter Kyle Kendrick pitched five innings and allowed three runs, one earned.

Mayberry, recalled Tuesday from Triple-A, hit a two-run homer in the second inning and a solo homer in the sixth. The multihomer game was the first of his career, and he has five home runs this season.

READ MORE: Man Struck, Killed By Vehicle In Northeast Philadelphia: Police

The Phillies’ first five runs scored with two outs.

Morrison’s homer off David Herndon in the sixth cut the Phils’ lead to 6-5. Florida tied the game in the seventh when Infante tripled and scored on a single by Ramirez.

The Marlins went on to load the bases with one out, but Drew Carpenter got Stanton to hit into a double play.

Florida scored three runs in the third, with two unearned because of an error on right fielder Brown. After Anibal Sanchez singled and Emilio Bonifacio walked, Gaby Sanchez hit a sharp single and continued to third when Brown misplayed the ball. Ramirez followed with an RBI infield hit.

For the second consecutive night, an intentional walk to Howard backfired on Florida. This time Raul Ibanez followed with a two-out, two-run double over the head of center fielder Bryan Petersen, who badly misjudged the drive and barely missed making the catch.

Philadelphia scored in the second when Brown walked with two outs and Mayberry hit his fourth homer. After Chase Utley walked in the third, the Marlins walked Howard, and both runners scored on Ibanez’s double to put Philadelphia up 4-0.

Ibanez had been 3 for 18 previously against Sanchez.

Rollins hit a two-out homer in the fourth for a 5-3 lead.

Notes: Utley improved his lifetime average against Sanchez to .484 (15 for 31). … Mike Cameron, a 16-year veteran acquired by Florida on Tuesday in a trade with Boston, pinch-hit in the eighth and fouled out. … The Phillies fell to 14-2 on Wednesdays.

(© Copyright 2011 The Associated Press. All Rights Reserved. This material may not be published, broadcast, rewritten or redistributed.)

MORE NEWS: Philadelphia Weather: Week Starts With Muggy Conditions Before Cold Front Arrives