BOSTON — The Boston Red Sox, winners of just 69 games last season but now poised for a return to the playoffs, pulled off a major deal late Tuesday night, acquiring Jake Peavy in a three-way trade.

Clearly worried about the immediate future of the injured Clay Buchholz and hoping to return to the playoffs for the first time since 2009, the Red Sox grabbed Peavy from the Chicago White Sox and sent rookie shortstop Jose Iglesias to Detroit.

The Red Sox (64-44) are a half-game behind the rampaging Tampa Bay Rays (64-43) in the AL East.

“We’re in a position to compete for a playoff spot,” Red Sox general manager Ben Cherington said on a conference call just after midnight Wednesday. “We’re very excited to bring Jake here. He’s a proven major-league starter.”

The Red Sox are also getting pitcher Brayan Villarreal from Detroit (he’s going to Triple-A Pawtucket and is coming back from a thumb injury) while sending three lower-level minor-leaguers to the White Sox, who are getting promising young outfielder Avisail Garcia from the Tigers.

Peavy, 8-4 with a 4.28 ERA in 13 starts with the White Sox this season, won the National League Cy Young Award with San Diego in 2007. The 32-year-old three-time All-Star is 128-97 with a 3.49 ERA lifetime. He was pulled back from a Tuesday night start against the Cleveland Indians, an indication he could be dealt by Wednesday’s non-waiver deadline.

Cherington said he has been talking to the White Sox for some time but when it became clear the two Sox didn’t match up, he got the Tigers involved. Talks were “in earnest” Tuesday, he said, and the deal was made late in Tuesday night’s game; Iglesias was pulled off the field for the ninth inning.

Peavy has one year left on his contract, plus a player option for 2015. He will make $14.5 million next season and $15 million in the option year.

Peavy is also reunited with Red Sox pitching coach Juan Nieves, with whom he had a great relationship when Nieves was a coach with the White Sox.

Cherington said the Red Sox, thrilled to be getting a veteran pitcher who is under their control for at least one more year, are picking up the entire contract. He added he didn’t know when Peavy would make his first start with his new team, but he said it would not be Wednesday.

Peavy had shoulder surgery in 2010 but Cherington said he has had no arm trouble since. He is coming off a fractured rib, an injury Cherington called “a freak thing.”

“Peavy is the right fit for us,” he said. “I think he’s excited to be coming here.”

“We cannot say enough about Jake’s intensity, effort, approach to the game and clubhouse leadership during his five seasons with the White Sox,” White Sox general manager Rick Hahn said in a statement. “Jake is a veteran competitor who makes his team better every day, not just when he takes the ball.”

Prior to the deal, Peavy said, “I’m not going to be shocked, overwhelmed by anything that happens. The way we went about it, as an organization, as friends, me and Rick, we’re pretty well prepared to face any situation we have to face, whether that’s staying or going.

“I commend and am thankful we’ve handled things the way they’ve been handled, and I think we’re prepared. I know I’m prepared with anything I’m faced with.”

Iglesias, who started the season hitting much better than anyone expected, has been slumping. He went 1-for-3 in Tuesday night’s win over Seattle but was in a 5-for-43 spin and had batted .167 in his last 18 games, without an extra-base hit or a walk.

The Tigers, who could be losing shortstop Jhonny Peralta to a Biogenesis suspension, have solidified their defense with the acquisition of the slick-fielding Iglesias, who played both shortstop and third base for the Red Sox and already has amazed people with his defense.

“We certainly didn’t go into July looking or expecting to trade Jose,” Cherington said, adding the Red Sox were dealing from depth on the left side of the infield.

“We are excited to be adding a quality player to our middle infield,” Tigers president David Dombrowski said. “He is a young player that will provide a lot of depth and has had success playing a variety of roles in the infield.”

Losing Iglesias creates a hole, but the Red Sox, who have Stephen Drew at shortstop, have major prospect Xander Bogaerts, primarily a shortstop, and more-experienced third baseman Will Middlebrooks at Triple-A Pawtucket. Brock Holt, who played well during his recent call-up, is also there, and a move will be made in time for Wednesday night’s game with the Mariners. Cherington said he did not expect a deal for another player for that area.

The Red Sox are shipping right-handers J.B. Wendelken and Francelis Montas and infielder Cleuluis Rondon to the White Sox.

Villareal was in the minors for the Tigers and will report to Pawtucket. He struggled this season (20.77 ERA in seven major league games) but was in 50 games for Detroit in 2012, going 3-5 with a 2.63 ERA.

Garcia, known as “Miguel Cabrera’s look-alike,” was in 30 games with the Tigers this season, hitting .241 with two homers and 10 RBIs. He has been up and down between the majors and Triple-A Toledo, for whom he was batting .374 after an 0-for-3 game Tuesday.