BOSTON — The Boston Red Sox needed a starting pitcher. The Detroit Tigers were looking for infield help. The Chicago White Sox wanted more prospects for the future.

And that’s why baseball’s biggest trade of the season came together.

The Red Sox acquired Jake Peavy from the White Sox in a blockbuster three-team deal on Tuesday night that also sent shortstop Jose Iglesias to the Detroit Tigers.

The slick-fielding Iglesias provides a nice insurance policy for AL Central-leading Detroit in case Jhonny Peralta is suspended as part of baseball’s Biogenesis drug investigation. Iglesias also can play second and third.

“The frank reality is that I do not know what is going to happen with Jhonny, but with this move, we now feel well protected if there is a long suspension,” Tigers general manager David Dombrowski said.

“We didn’t feel we were well protected in that situation with our internal options. If it were a 15-day thing, like a typical injury, I think we could have comfortably dealt with it with the players we already have, but when you start to talk about 50 days and a possible playoff run, we feel better going ahead with Jose.”

Peavy is 8-4 with a 4.28 ERA in 13 starts this season. The 2007 NL Cy Young Award winner was considered the best starting pitcher on the market ahead of Wednesday’s non-waiver deadline.

“If there’s one thing we wanted to do — if we could pull it off — is to add a starting pitcher as we look at the next two months,” Boston general manager Ben Cherington said.

Peavy tweeted a message to White Sox fans after the deal was done:

“THANK YOU Chicago! It’s been an honor & a privilege to pitch for u! You are 1st class & I will never forget you! So many emotions right now!”

With Clay Buchholz on the disabled list with a shoulder problem, the move gives Boston another proven starter for the stretch run in the tough AL East. It also could strengthen the bullpen if the Red Sox decide to return rookie Brandon Workman to a relief role if Buchholz comes back.

“We thought Peavy, of the starting pitchers available, was the right fit for us,” Cherington said. “It just came together that this was the deal we thought made the most sense.”

The Red Sox also got reliever Brayan Villarreal from the Tigers. They shipped Iglesias to Detroit and three minor leaguers to the White Sox as part of the trade.

Chicago also received prized prospect Avisail Garcia. Garcia, who turned 22 in June, hit .374 with five homers and 23 RBIs in 33 games for Triple-A Toledo.

The outfielder, who was the Tigers’ minor league player of the year last season, was assigned to Triple-A Charlotte.

“We’re very excited about his upside,” general manager Rick Hahn said. “We truly feel this is a five-tool player, someone who’s not only going to hit for average but for power, run well, play above-average defense.

“He’s still young and he still has a little bit of development ahead of him, but we feel we’ve acquired someone with a great deal of upside who’s going to have a big impact on the South Side for many years to come.”

Peralta is among a group of players who have been linked in media reports to Biogenesis, a closed Florida anti-aging clinic that was accused by Miami New Times in January of distributing banned performing-enhancing drugs, sparking an investigation by Major League Baseball. The league could hand down multiple suspensions as part of the case in a matter of days.

The 23-year-old Iglesias hit .330 with a home run and 19 RBIs in 63 games with the Red Sox, who trail division-leading Tampa Bay by a half-game. He was the AL rookie of the month for June, when he batted .395 with six RBIs.

“Jhonny Peralta is our shortstop until someone tells us he can’t be our shortstop,” Dombrowski said. “If that happens, we are very comfortable with Jose going forward, but until then, we have a talented young player who can play second base and third base very well.”

Cherington said discussions with the White Sox had been going on for some time, but the two teams couldn’t agree on a deal until the Tigers joined the mix.

By giving up a young asset in Iglesias, Cherington said the Red Sox wanted a player for the future as well as the stretch run this season. Cherington said there was no cash involved in the deal and the Red Sox are assuming all of Peavy’s contract, which includes a $14.5 million salary for next year and an incentive-laden player option for 2015.

“He’s an intense competitor. He loves to pitch,” Cherington said. “I think he’ll fit in nicely with the group that we have.”

Cherington said Boston was familiar with Peavy’s medical history and comfortable the 32-year-old would be a healthy addition.

“We’re going to get Jake here and get him into the mix,” Cherington said. “It won’t be tomorrow. We don’t know quite yet when it will be.”

The other minor leaguers headed to Chicago are infielder Cleulius Rondon and pitchers Francelis Montas and Jeffery Wendelken. Each of them were at the Class-A level with the Red Sox.