ST. PETERSBURG, Fla. — Now that they’re back at the break-even point, the Tampa Bay Rays want to keep going and going.

Alex Cobb pitched neatly into the eighth inning, and the Rays became just the fourth team in major-league history to reach .500 after falling 18 games under in the same season, beating the Yankees 5-0 Friday night.

“Really proud of the boys,” manager Joe Maddon said. “It was not easy.”

The Rays won their third straight and sent New York to its fifth straight loss.

Tampa Bay also accomplished the comeback feat in 2004 when known as the Devil Rays. The 1899 Louisville Colonels and 2006 Florida Marlins also got back to .500 after dropping 18 under.

The Rays (61-61) were 24-42 on June 10. They are trying to become the first club to finish with a winning record after being so far under.

“It started with Joe and not letting us believe that we were that team,” Cobb said. “It’s mind-boggling that we went through the stretch we did, but we’re back on track now.”

Cobb (8-6) gave up six hits in 7⅓ innings, striking out eight and walking one. He improved 4-0 in six career home starts against the Yankees.

“Fabulous,” Maddon said.

Cobb landed awkwardly on his left foot after fielding Brett Gardner’s grounder in the sixth. He said the foot is fine but expected some stiffness today.

After giving up a single to Derek Jeter that loaded the bases, Brad Boxberger struck Jacoby Ellsbury and Mark Teixeira.

“We didn’t score,” New York manager Joe Girardi said. “That was the problem.”

Tampa Bay has held its opponents to three runs or fewer in a club-record 11 consecutive games.

Brandon McCarthy (4-2) gave up four runs and seven hits over 6⅓ innings. 

The Rays took a 2-0 lead in the first on RBI grounders by Evan Longoria and James Loney.

Loney homered in the eighth when Esmil Rogers tried to quick pitch him.