Brian Anderson also went deep and drove in two runs for the Marlins, who earned a split of the four-game series.
Rookie infielder Tommy Edman homered for the Cardinals, who rallied from 4-1 and 5-3 deficits.
Riddle connected off Andrew Miller (3-3) with one out for a 7-5 lead.
Jarlin Garcia (1-0) got the win with two innings of relief, and Sergio Romo closed for his 13th save in 14 chances. He gave up a two-out RBI double to Yadier Molina, but ended the game by picking off pitcher Jack Flaherty at second base. Flaherty was pinch-running for Molina.
Edman tied it 5-all with a two-run homer off Tayron Guerrero in the eighth. It was Edman’s first career round-tripper and it came in his 10th at-bat.
Gallen gave up one run and five hits in five innings. He struck out six and walked two.
St. Louis starter Adam Wainwright allowed three runs and six hits over 5 1/3 innings in his return from the injured list. The veteran right-hander, who strained his left hamstring running the bases June 9, struck out six and walked one.
Anderson hit a solo homer off John Brebbia in the eighth to push Miami’s lead to 5-3. It was his ninth of the season. Anderson also broke a 1-all tie with an RBI double off the glove of third baseman Matt Carpenter in the sixth.
Miguel Rojas gave the Marlins a 4-1 advantage when he knocked in a run with an infield single in the seventh.
Source: Fox Sports