ST. LOUIS — With some help from Miami's hitters, Jose Urena finally got his first win of the season.

Brian Anderson and J.T. Riddle homered to back a shaky Urena, and the Marlins stopped a six-game losing streak with a 7-4 victory Tuesday night over the St. Louis Cardinals.

Anderson had a two-run homer and two singles for Miami, which had lost nine of 10.

"I think everyone kind of had a piece of the pie there," Anderson said. "It was awesome to get a win for Jose there, too. He's been grinding for us."

Urena (1-7) pitched five innings, allowing 10 hits and four runs for his first win in 13 starts this season. Miami lost his previous 14 overall — a dubious team record — dating back to Sept. 26 last year. Urena started on opening day this season but his last win came on Sept. 20, 2017.

"It's good to get Jose on the board," Marlins manager Don Mattingly said. "It seemed like one of those nights he didn't have his great stuff, but he hung in there enough and the boys were swinging the bats a little bit so it ended up being good for him."

Kyle Barraclough pitched the ninth for his second save.

In getting swept last weekend, the Marlins allowed 21 runs at Arizona and scored only four times. Miami entered the St. Louis series 1-6 on this road trip with a minus-22 run differential.

The Cardinals returned their opening day battery from the 10-day disabled list for the series opener, with right-hander Carlos Martinez and catcher Yadier Molina coming back from injuries.

Martinez wasn't sharp while making his first start in four weeks since straining his right lat muscle in a May 8 loss to Minnesota. The right-hander threw 75 pitches in four innings, snapping a string of 65 straight starts in which he pitched into the fifth, dating back to 2016.

He allowed four hits and two runs with five walks and five strikeouts but was helped by three double plays.

"I threw all my pitches good," Martinez said. "My arm feels good. Today was like a working day. I was trying to compete."

Preston Guilmet (0-1) made his Cardinals debut after they called him up Tuesday from Triple-A Memphis. It was a forgettable one inning of work.

It was the first time St. Louis lost this season with 12 or more hits.

"Some days are tougher than others," manager Mike Matheny said.

In his first game against his former team, St. Louis outfielder Marcell Ozuna went 3 for 4 with an RBI. In his last four games, Ozuna has gone 8 for 14, including a milestone 100th home run and grand slam, with six RBIs.

The Marlins scored three runs off Guilmet for a 5-2 lead in the fifth. Derek Dietrich scored on a sacrifice fly by Justin Bour. Anderson hit a two-run homer that just cleared the fence in right field to score J.T. Realmuto.

St. Louis got two runs back in the fifth. Tommy Pham drove in a run with a bases-loaded fielder's choice. Ozuna followed with a run-scoring single, but Urena picked Pham off third and got a groundout to end the inning.

"Very unique pickoff play," Matheny said. "It caught us off guard. That's a big spot there, too. It's not a play you see very often but they executed it and pulled it off."

Miami added two runs off reliever Austin Gomber in the sixth to make it 7-4. Riddle led off with a homer and J.B. Shuck scored on a sacrifice fly by Dietrich.

St. Louis took a 1-0 lead in the second when Ozuna ran through a stop sign at third to score on a single to left by Molina.

Miami scored twice in the third. Starlin Castro scored on a double play and Dietrich came home on Anderson's infield single that hit Martinez's glove and glanced off his shoulder.

The Cardinals made it 2-all in their half of the third. Matt Carpenter scored when Pham hit into a double play.

GOOD CATCH

Dietrich ran almost to the infield to make a sliding catch of a short fly to left hit by Jose Martinez in the first inning. Dietrich rolled over, popped up and fired to first base to double up Carpenter. It was his first career outfield assist.

ROSTER MOVES

St. Louis optioned right-hander Mike Mayers to Triple-A Memphis, where catcher Steven Baron was designated for assignment to make room for Guilmet on the 40-man roster.

TRAINER'S ROOM

Marlins: RHP Nick Willgren is on the 10-day disabled list with a bruised right middle finger.

Cardinals: INF Greg Garcia has been placed on the paternity list. Garcia likely will return Thursday following the birth of his first child, a girl named Olivia.

UP NEXT

Marlins: LHP Wei-Yin Chen (1-3, 6.10 ERA) makes his second career start at St. Louis and first since July 16, 2016. In his most recent outing, Chen lasted only 1 2/3 innings at San Diego.

Cardinals: RHP Jack Flaherty (2-1, 2.62) faces Miami for the first time. In his last start, Flaherty did not earn a decision at Pittsburgh as he matched his shortest outing of the season (five innings).