SAN FRANCISCO (AP) - Justin Bour hit his 20th home run, Marcell Ozuna drove in two runs and the Miami Marlins held on to beat the San Francisco Giants 5-4 on Saturday night.

Christian Yelich and J.T. Realmuto added two hits apiece and All-Star Giancarlo Stanton doubled and scored while helping Chris O'Grady to a victory in his major league debut for the Marlins.

San Francisco scored a run in the ninth off closer A.J. Ramos and had runners at the corners with two outs before Hunter Pence struck out looking to end the game.

Three months after being released outright by the Los Angeles Angels' Double-A team before signing a minor league contract with Miami in May, O'Grady (1-0) celebrated his debut with a workman-like effort. The rookie pitcher allowed three runs on five hits over 5 1/3 innings with four strikeouts and two walks.

Samardzija (4-10) allowed four runs in seven innings.