Morrison made a nice grab on a sharp grounder to his right, but elected to take the ball to the bag himself rather than flipping it to Miami starter Henderson Alvarez. Morrison slid into first too late, accidentally spiking a safe Sandoval.
Sandoval took Morrison's spikes to his left cheek and left forearm, and Alvarez landed on top of San Francisco's third baseman.
The infield single drove in a run to put San Francisco up 1-0 and improved Sandoval's batting average with runners in scoring position to .370 (40-for-108).
Giants manager Bruce Bochy praised Sandoval's "great hustle."
"That probably won the game for us, kept the rally going," Bochy said. "I thought he jammed his fingers. He laid there on the ground, and I said, 'Oh, geez. He did something to his shoulder or finger,' but he's doing all he can to beat Morrison to the bag, and that hustle there won the game."
Sandoval added: "That's the kind of guy that I am. I play hard every day. No matter what the situation, I just come in and try to help my team and drive a run home to home plate."
Marlins manager Mike Redmond defended Morrison's decision to take the ball to first base rather than tossing it to Alvarez.
"On that play, you have a split-second to decide," Redmond said. "[Alvarez] was definitely late getting off the mound, but he did make up the ground. But once LoMo saw Henderson was late, he just put his head down and tried to see if he could beat him to the bag.
"[Alvarez] did look like he got over there in time. You have about a half-second to decide what you're going to do there. Unfortunately, it didn't work out for us."
Alvarez then balked in a run and gave up a two-run triple to Gregor Blanco, putting San Francisco ahead, 4-0, heading into the bottom of the fourth.
The advantage proved more than enough for Cain, who continued his second-half surge by notching a fifth consecutive quality start. He gave up only two runs on four hits with two walks and five strikeouts in seven innings.
"I felt good," Cain said. "[Catcher Buster Posey ] and I kind of got things going early. We were throwing strikes and letting the defense work."
The Giants hurler's lone mistake came against the most dangerous Marlins player -- slugger Giancarlo Stanton.
In the bottom of the sixth, Cain threw a 93-mph fastball up and in to Stanton, who smacked a 446-foot home run to left field to cut the deficit to 4-2.
Stanton's homer was his first in 59 at-bats, a drought that dated back to July 28.
The home run came one pitch after Cain did not get the strike call he wanted on a 2-2 check swing by Stanton. Cain channeled his frustration by striking out the side.
The right-hander admitted his emotions stemming from the Stanton at-bat fueled him for the remainder of the sixth.
"That was probably definitely heated," Cain said. "Being a starter, I've been in those situations before. For me, I can't do that the whole game. It's not possible. You can use that kind of emotion sometimes just for an inning and kind of get over it.
"But I can't pitch that way. It'll take too much out of you."
Bochy added: "It's not a bad way to pitch as long as you can control it."
While Stanton's home run was the one time the Fish took advantage of Cain, it was far from the only noise the home team made offensively.
The Marlins got a leadoff single from Christian Yelich in the bottom of the fourth, and Cain later issued walks to Stanton and Ed Lucas to load the bases with two outs.
But on a night that saw Cain show off his talented arm, he escaped trouble with his glove. The hurler made a nice play on a sharp Adeiny Hechavarria grounder to end a promising Miami threat.
San Francisco tacked on two more runs in the top of the eighth with a dose of plate discipline. Brandon Crawford, Brandon Belt, Posey and Sandoval all drew walks in the frame to push a fifth run across.
Andres Torres, pinch-hitting for Roger Kieschnick, capped the Giants' scoring with an infield RBI single. Those final runs proved critical when the Marlins plated two runs in the bottom of the eighth against reliever Santiago Casilla.
"We needed those two runs, because they came back," Bochy said. "We made a mistake there, let them back in it. But Casilla, he settled down and he threw great."