Jazz Chisholm Jr. also homered for the Marlins. Marte's shot to left-center field off reliever Wandy Peralta sent Miami to its fifth victory in six games.
Pinch-hitter Jesus Aguilar began the decisive rally with a one-out walk against reliever Matt Wisler (0-2). Corey Dickerson's single advanced pinch-runner Magneuris Sierra to second.
''My approach was to hit the ball up the middle because I had the runner in scoring position,'' said Marte, who has reached base safely in 12 straight games. ''I got a good pitch and everything went well.''
Anthony Bass (1-2) pitched a perfect eighth and Yimi Garcia closed with a scoreless ninth for his third save. Marlins pitchers limited the Giants to five hits.
The start of Miami's second homestand followed a 4-2 road trip, which included three wins at defending NL East champion Atlanta.
''Obviously, we played well on the trip,'' manager Don Mattingly said. ''You like to get this thing started in a good way and obviously tonight we did.''
San Francisco struck first on Evan Longoria's RBI single off starter Daniel Castano in the fourth. Longoria drove in Mike Yastrzemski, who doubled to open the inning.
''Our hitters are feeling some frustration now,'' Giants manager Gabe Kapler said. ''The lineup that we put out today I think we have a lot of confidence in long term.''
Chisholm's leadoff homer in the fifth tied it. Chisholm drove Anthony DeSclafani's slider over the wall in right for his third homer and fifth consecutive game with an extra-base hit.
DeSclafani allowed four hits and struck out four in six innings. He has yielded two runs in his three starts this season.
Castano was lifted for a pinch-hitter in the fifth. The left-hander permitted one run, three hits and two walks in his season debut. Although he left without striking out a batter, Castano induced 10 groundball outs.
''They're a tough lineup, very competitive. Anything close, they weren't really swinging at,'' Castano said. ''It was so great to get back out there. So excited to be back on the mound, get that rhythm going. I started to feel better as the game went on.''
Before his home run, Chisholm spotted a fan in the stands displaying a sign that highlighted the dyed blue hair the Marlins rookie has sported early in the season.
''I actually had looked at him the pitch before and saw his sign and the blue hair and I was like, check that out!'' Chisholm said. ''First time hitting a homer at (home), the stadium is erupting. It was one of the coolest moments I've had so far in baseball, having an at-home homer.''
Giants: RHP Johnny Cueto (right lat strain) is expected to miss at least two starts, Kapler said. RHP Camilo Doval was promoted from minor league camp to replace Cueto.
Marlins: RHP Elieser Hernandez (right biceps inflammation) and RHP Sixto Sanchez (mild right shoulder inflammation) are progressing with their throwing programs.
Giants RHP Aaron Sanchez (0-1, 2.70 ERA) starts the middle game of the series Saturday against RHP Sandy Alcantara (0-1, 2.45).
More AP MLB: https://apnews.com/hub/MLB and https://twitter.com/AP-Sports
Copyright 2021 STATS LLC and Associated Press. Any commercial use or distribution without the express written consent of STATS LLC and Associated Press is strictly prohibited.