Hairston, 33, was hitting just .172 with eight home runs and 19 RBIs in 99 at-bats this season for the Cubs. He had a pinch-hit home run during Chicago's 4-3, 11-inning victory against the Pittsburgh Pirates earlier Sunday.
Pineyro is a 21-year-old right-hander who went 6-3 with a 3.24 ERA over stints with Single-A Hagerstown and Potomac.
"It was a good opportunity for us to acquire a young pitcher that we liked," Cubs GM Jed Hoyer said. "We've had good reports on Pineyro going back as far as the Instructional League last year. Solid reports this year. He's a young arm we're excited to get and add to our system."
There will also be players to be named later from both sides involved.
"I don't anticipate it affecting the overall balance of the trade," Hoyer said.
The Cubs will add minor league pitcher Brooks Raley to take Hairston's spot on the roster.
"For a couple days at least we'll keep Brooks Raley up here," Hoyer said. "Our bullpen is pretty taxed right now. We would like to add another right-handed bat."
ESPNChicago.com's Jesse Rogers contributed to this story.