Miami struggled to manufacture runs against Cain over his 6 2/3 innings, and the righty held the Marlins to two runs -- one earned -- on five hits and only allowed one baserunner through the first four frames.
The Marlins were able to push one across in the fifth, when Giancarlo Stanton drew a leadoff walk and Logan Morrison followed with a well-timed bunt for a hit, the first of his career, to put two aboard. That set up a two-out RBI single from the struggling Chris Coghlan with Nolasco on deck.
Miami got to Cain again in the seventh when a two-out single from Jose Reyes cut the Giants' lead to 3-2 when he extended his hit streak to eight games and ended Cain's afternoon.
"I wanted to make sure that I was staying locked in," Cain said. "Some days it's easier to do that than others and some days you might show more emotion than others."
Nolasco, meanwhile, worked his way through seven solid innings en route to his fifth quality start of the season. However, Giants left fielder Melky Cabrera stood in the way of the righty's attempt to build on his Marlins franchise career win record.
Cabrera was a problem for Marlins pitchers all series, and on Sunday, he was a one-man wrecking crew.
The switch-hitter, who has been one of the hottest hitters in the Majors this month and who leads the league in hits, belted a solo home run off Nolasco with two outs in the first. It was his fourth home run of the year and his second in the four-game series.
He finished the game 4-for-4 -- adding a single in the fourth, sixth and eighth innings -- and scored all three of San Francisco's runs.
"He's just hot right now," Nolasco said. "There's not much you can do. You still make your pitches on him and he still finds a hole. ... It's not fun seeing him when he's hot like that."
For the series, Cabrera was 9-for-18 with a pair of doubles and a triple to go with his two round-trippers. His four hits Sunday tied a career high, last set May 20 against Oakland.
"Melky was a one-man show this week. He hit everything we threw," Guillen said. "Melky's a pretty good hitter, a very, very good hitter."
Outside of Cabrera and cleanup hitter Buster Posey, who finished 2-for-4 with an RBI double, Nolasco cruised through the Giants' order, holding the other seven spots in the lineup hitless.
He gave up three runs on five hits, giving the Marlins a chance to win, but Miami squandered opportunities with runners in scoring position in the fifth, sixth and seventh innings. The team went 2-for-10 with runners in scoring position on the afternoon.
The Marlins got the tying run on base in each of the final two frames, but couldn't capitalize. Morrison and newly acquired outfielder Justin Ruggiano both struck out to strand Stanton at first in the eighth. Then after John Buck saved a run in the top of the ninth by thwarting San Francisco's attempt at a suicide squeeze, Reyes grounded into a fielder's choice with Brett Hayes aboard to end the game.
Despite dropping the series finale and splitting the four-game set at Marlins Park, the Marlins took the season series from the Giants, winning five of seven matchups. They head into Monday's series opener with the first-place Nationals just three games back and looking to gain ground in the National League East.
"We know it's not going to be easy because the Nationals have been playing very good baseball," Reyes said, "but at the same time, we've been very good too."