Updated

ST. PETERSBURG, Fla. (AP) -- Tim Beckham is making the most of his latest opportunity to prove himself with the Tampa Bay Rays.

The first overall pick from the 2008 draft homered twice for the second time in eight games, driving in four runs to lead the Rays over the struggling Miami Marlins 5-1 on Thursday night.

The 27-year-old shortstop, demoted to the minors last September and filling in this season for the injured Matt Diffy, is batting .338 with two doubles, two triples, six homers and 15 RBIs in his last 17 games.

"Playing every day, you get opportunities to make adjustments and to compete more, and that's what the game's about," Beckham said. "You've got ups and downs throughout the season. How you take your downs speaks a lot about you, how you embrace the struggle, how you embrace different opportunities speaks a lot about you."

Matt Andriese (2-1) scattered five hits, walked three and struck out eight over seven innings to match his longest outing this season. Dee Gordon hit a run-scoring single off Chih-Wei Hu in the ninth before Alex Colome got the final out for his eighth save.

The Rays won three of four games to take the Citrus Series between the intrastate rivals, winning twice before small crowds in Miami before returning home to mostly-empty Tropicana Field on Wednesday and Thursday. The attendance was announced as 10,118 for the series finale.

Beckham had a pair of two-out, two-run homers, the only hits off Dan Straily (1-2) through four innings. Kevin Kiermaier added a RBI single off Nick Wittgren's glove to make it 5-0 in the sixth.

Straily, who gave up a leadoff double to Evan Longoria in the fifth, allowed four runs and three hits in five innings. Two of his five walks preceded Beckham's home runs.

"That whole game turned on two pitches," Straily said. "It just goes to show you, you never know what pitch is going to affect the game. It's very frustrating."

Beckham had the first multi-homer game of his career April 26 at Baltimore. He had 10 RBIs in 11 career games, including six starts, against Miami.

The Marlins have lost seven of nine games to fall a season-low-tying three games under .500 (12-15).

"For the most part, I'm not overly concerned," Miami manager Don Mattingly said. "I like my club, confident that we're going to play better than this, and we're going to get more consistent than this."

TRAINER'S ROOM

Marlins: Gordon was back in the lineup after having the previous night off.

Rays: C Wilson Ramos, coming back from right knee surgery, has been cleared for limited catching drills. … RHP Erasmo Ramirez was placed on the paternity list and Hu was recalled from Triple-A Durham.

OZUNA ZONE

Marlins LF Marcell Ozuna singled in the second inning, giving him at least one hit in each of the 21 games he's faced Tampa Bay during his career. That's the longest-active hitting streak against a single opponent in the majors. Boston's Dustin Pedroia has a 20-game streak against the Oakland Athletics.

CITRUS SERIES

The four-game home-and-series drew crowds of 16,095 and 16,011 in Miami on Monday and Tuesday before dipping to 12,285 and 10,118 for the pair in St. Petersburg. The Rays improved to 55-52 all-time against the Marlins.

RARE FEAT

Miami's J.T. Realmuto got his second triple of the season hitting leadoff Wednesday. According to Elias, Realmuto became the first catcher since Pittsburgh's Jason Kendall (2001 and 2002) to have two triples in a season from the leadoff spot. Prior to Kendall, the last catcher to do it was Mickey Cochrane in 1925.

UP NEXT

Marlins: RHP Tom Koehler (1-1) takes the hill Friday night against New York Mets RHP Rafael Montero (0-2). Miami was won five of seven in the season series.

Rays: RHP Chris Archer (2-1) faces Toronto LHP Francisco Liriano (2-2) Friday night. Manager Kevin Cash said he doesn't anticipate any carry-over from last Sunday when Jose Bautista glared at the mound after Archer threw behind him in the first inning. Archer said the pitch got away from him.