The Padres announced the trade before Thursday's game against the New York Mets at PETCO Park.
Gaudin, 26, was 4-10 with a 5.13 ERA in 20 appearances for the Padres, including 19 starts. He allowed six earned runs on nine hits in 3 1/3 innings in a 6-2 loss Sunday to the Atlanta Braves.
San Diego general manager Kevin Towers said that he spoke with Yankees general manager Brian Cashman on Friday about Gaudin, but Towers was obviously swamped with the Jake Peavy trade to the White Sox that happened minutes before the Trade Deadline.
As for Gaudin, he was looking forward to playing in New York and for a team that's contention for a postseason spot.
"I'm excited to go to New York," he said. "I love to win and that's what they do.
"It was fun [playing in San Diego]. I had a great time. It was a real good situation here. I'm thankful to KT [Kevin Towers] to be part of the team."
Gaudin, who signed a Minor League contract with the Padres on April 12, allowed nine runs in his last two starts covering five innings.
The Padres have yet to announce a corresponding roster move or who will start when Gaudin's turn comes up in the starting rotation.
Gaudin is 32-35 with 4.58 ERA in 205 career games with the Rays, Blue Jays, A's, Cubs and Padres.
Corey Brock is a reporter for MLB.com. This story was not subject to the approval of Major League Baseball or its clubs.