Cobb (3-1) gave up three hits, one of them when Brett Gardner singled with one away in the ninth. Fernando Rodney then came on to preserve the three-run lead, but immediately gave up a single to Ichiro Suzuki.
The Rays took two from the Yankees in the three-game series and won for the sixth time in seven games.
Andy Pettitte (3-1) gave up seven hits and three runs over six innings in his first setback of the season. He struck out a season-high 10.
Tampa Bay's recent run of success has come after the Rays won just four times in their opening 14 games.
Ray Liotta sues skin care company over use of likeness
Aaron Carter is still in love with Hilary Duff