MIAMI (AP) — Brad Lincoln pitched six innings to earn a victory in his first start of the season Monday, and the Pittsburgh Pirates ended a streak of eight consecutive losses against the Marlins by winning 3-2.

Lincoln (3-0), who had come out of the bullpen in his seven previous appearances this season, departed for a pinch-hitter with a 3-2 lead and an ERA of 1.33. He allowed four hits and walked one.

The Pirates, who rank last in the majors in runs, won with only six hits. Rod Barajas, who came into the game batting .162, hit his second homer, and Pedro Alvarez put Pittsburgh ahead to stay with an RBI double in the sixth.

The Pirates started a seven-game, three-city trip with their third victory in a row, and they’re within one game of .500. They hadn’t beaten the Marlins since 2010 and went 0-6 against them last year.

Three Pittsburgh relievers combined to shut out Miami over the final three innings. The Marlins had runners at first and third with one out in the eighth, but Jason Grilli struck out Logan Morrison and got Giancarlo Stanton to pop out.

Joel Hanrahan pitched a perfect ninth for his seventh save in eight chances. The bullpen lowered its ERA to 2.54.

Miami’s Anibal Sanchez (2-1) went seven innings for the fifth start in a row and allowed three runs.

Hanley Ramirez hit his seventh home run for the Marlins, but they otherwise mustered little support for Sanchez. They’ve scored only 12 runs in his past five starts.

Miami, which began the week last in the majors batting with runners in scoring position, went 1 for 8 in those situations.

Pittsburgh went ahead for the third and final time when Alvarez doubled home Andrew McCutchen, who had singled.

The Pirates took a 1-0 lead in the first. Jose Tabata led off with a double, took third on a flyout and scored on a sacrifice fly by McCutchen. Barajas homered in the second.

Miami came from behind twice. Ramirez’s homer in the second made the score 1-all, and Emilio Bonifacio hit a two-out RBI single in the fourth to tie the game at 2.