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.
St. Louis trimmed the deficit to 4-3 in the bottom half when Paul Goldschmidt hit an RBI double and scored on Marcell Ozuna’s single.
Marlins: 1B Garrett Cooper was pulled in the fifth with left triceps tightness. He is day-to-day. Cooper, who missed Wednesday’s game with the same problem, extended his hitting streak to a career-high 12 games with a double in the fourth. … Miami catcher Jorge Alfaro exited in the ninth with concussion-like symptoms.
Cardinals: INF Yairo Munoz came off the paternity list and was placed on the restricted list due to travel delays in his return to St. Louis. … INF Jedd Gyorko remains on the injured list with calf and back ailments. “It’s going to be a little while. The calf strain is more significant than the back injury had been,” general manager Michael Girsch said. Gyorko went on the injured list June 8.
Marlins: RHP Sandy Alcantara (3-6, 3.73 ERA) will face Phillies RHP Aaron Nola (6-1, 4.89) in the opener of a three-game series at Philadelphia on Friday. Alcantara game up a season-high six runs on a career-high 11 hits over five innings in a 9-1 loss to Philadelphia on April 12 in Miami.
Cardinals: RHP Michael Wacha (4-3, 6.00) opposes Los Angeles Angels RHP Griffin Canning (2-3, 3.93) in the opener of a three-game interleague set Friday.
More AP MLB: https://apnews.com/MLB and https://twitter.com/AP_Sports