In the seventh, Yankees reliever David Aardsma uncorked a wild pitch that allowed Travis Snider to score from third base, and Jeff Larish added a pinch-hit RBI single off Aardsma later in the frame.
One of the runs was charged to left-hander Boone Logan, who was struck by a line drive off the bat of Jose Tabata earlier in the frame and was forced to leave the game.
Logan, who is considered a lock to be in the Yankees' bullpen, was hit in his left hip, but he said he's fine and expects to pitch again Friday.
Hiroki Kuroda spun six innings of scoreless, one-hit ball in his final start of the spring. Slotted to be New York's No. 2 starter, Kuroda walked none and struck out five in the outing.
Locke, who was informed that he will begin the season as the Bucs' fifth starter, allowed four hits over six scoreless innings. Locke walked none and struck out three.
Up next: The Pirates' Grapefruit League season ended Thursday at George M. Steinbrenner Field, but they will play one more game before Sunday's pre-Opening Day workout and Monday's season opener against the Cubs at PNC Park. Pittsburgh will play its Double-A affiliate in Altoona on Saturday at 2:05 p.m. ET.