"We all have different needs right now, and my needs are I'm in a little bit of a roster crunch," Cashman said. "Making this move now frees up a little more of that roster crunch. So I appreciate what [Pirela] did for us and wish him good luck out in San Diego."
Cashman likened the deal to a move he made earlier this month involving right-hander Chris Martin, whose rights were sold to the Nippon Ham Fighters in Japan for $750,000.
Herrera, 20, went 8-7 with a 4.08 ERA in 26 games (25 starts) between the Padres' Class A Advanced affiliate in Lake Elsinore and Double-A club in San Antonio this year.
He was acquired by the Padres from the A's in the trade that sent outfielder Kyle Blanks to Oakland in May 2014. Herrera is 23-24 lifetime with a 3.79 ERA in 82 games (74 starts) spanning four Minor League seasons.
Pirela, 25, hit .230 with a homer and five RBIs in 37 games with the Yanks this past season. He missed the first month of the season while on the concussion disabled list following an injury sustained during a March 22 Spring Training game.
In 64 Minor League games between Tampa, Trenton and Triple-A Scranton/Wilkes-Barre, Pirela hit .310 with three homers and 23 RBIs. He was signed by the club as a non-drafted free agent in 2006 and made his Major League debut in 2014.
"I think there was a choice whenever we had to make a phone call down there," Cashman said. "[Pirela is] very versatile; max-effort guy on everything he ever did, which was great. Amazing attitude. Could swing the bat. But right now, again, I had to find ways to free up roster spots."
Bryan Hoch is a reporter for MLB.com. Follow him on Twitter @bryanhoch, on Facebook and read his MLBlog, Bombers Beat. This story was not subject to the approval of Major League Baseball or its clubs.