The Boston Red Sox traded away a pitcher who might have been their future ace for several years. And the reason is simple:

They had to if they wanted to see the postseason this year.

Boston traded Anderson Espinoza to the San Diego Padres on Thursday for All-Star left-handed pitcher Drew Pomeranz, who will start Wednesday in Boston.

“He’s got quality pitches,” said Dave Dombrowski, the Red Sox president. “We think he has pretty good stuff.”

Dombrowski got the quality starting pitcher he said his team needed – one who won’t be a free agent until after 2018 – and San Diego received one of the best pitching prospects in the game.

In terms of stuff, Espinoza brings the heat with a fastball that has reached 100 mph, with a solid curveball. Pomeranz (8-7, 2.47 ERA) has a fastball in the low 90s, with a new cut fastball and curve.

But Dombrowski wasn’t looking at the radar gun when he made this trade. His eyes were on the American League East standings.

While the Red Sox have the major league’s best offense – 490 runs, .833 OPS – they are tied for second place in the East, two games out. If Boston wanted to surge ahead of Toronto and catch Baltimore, it needed to improve its pitching – ranked 19th with a 4.43 ERA.

Dombrowski traded for reliever Brad Ziegler last Saturday, and now got his starter.

“We’ve addressed some major needs,” said Dombrowski, who may not be done dealing. “You can always get better.”

In Pomeranz, Boston may have obtained the best starting pitcher available. According to the WAR rankings on fangraphs.com, Pomeranz ranks 16th in the majors with a 2.5. No pitchers ahead of him are on the market, unless you think the Marlins would trade Jose Fernandez (third, 3.9) or the White Sox would deal Chris Sale (11th, 2.6).

The Pomeranz-for-Espinoza trade features both reason and gambles for each team.

San Diego dealt a young pitcher, 27, who was making only $1.35 million. But he will earn a lot more with arbitration over the next two years. The Padres get a great prospect – the fourth-best pitching prospect in the minors, according to Baseball America – but one who is four steps away from the majors in low Class A.

The Red Sox, who have had trouble developing starting pitchers, just traded the best arm in their minor league system.

“He’s a youngster we liked a great deal.” Dombrowski said. “Not someone we wanted to give up. But if we were going to acquire someone like Pomeranz…

“It’s a sacrifice for the future but we’re deep enough to cover it up.”

Boston is getting a solid starter, but one who has been in and out of the bullpen until this season.

Plus, getting a National League pitcher hasn’t always translated to American League success. (In 2003, Boston got Jeff Suppan and his 3.57 ERA from Pittsburgh. His Red Sox ERA was 5.57.) Pomeranz has faced one AL team this year, beating the Yankees 2-1 on July 2 in San Diego (seven innings, five hits, one run).

Pomeranz was the Cleveland Indians’ first-round draft pick in 2010 and traded to Colorado the next year in the Ubaldo Jimenez deal. He made it to the majors that year and was a full-time starter in 2012 (2-9, 4.93). He’s been in and out of the bullpen since.

Oakland acquired Pomeranz before the 2014 season and used him mostly as a reliever. The Padres traded for him this past offseason and made him a full-time starter again. He had a 4.07 ERA before this year, but an added cut fastball has made a difference.

According to Fangraphs, Pomeranz used to rely on his fastball a lot – nearly 70 percent of the time. With a cutter this year, his arsenal is fastball (48 percent), cutter (13 percent) and curve (39 percent).

“He has a premium curveball,” Dombrowski said.

Pomeranz is second in the majors in opponents’ batting average (.184). He has 115 strikeouts and 41 walks in 102 innings.

Pomeranz joins a Boston rotation of David Price, Stephen Wright, Rick Porcello and Eduardo Rodriguez (with Clay Buchholz around in case Rodriguez struggles more). The five starters are under Boston’s control for at least two more years.

Espinoza, 18, was first scouted by the Red Sox when he was a 14-year-old in Venezuela. He signed at 16 for $1.8 million. Espinoza began his pro career last year and zipped through the system, jumping from the Dominican Summer League to the Gulf Coast League in Florida, then skipping short-season Lowell to make a start for Greenville. He had a combined 1.23 ERA with 65 strikeouts in 58 innings.

This year, as the youngest pitcher in the low Class A South Atlantic League, Espinoza had a 4.38 ERA with 72 strikeouts in 72 innings.

With Espinoza gone, Boston still has young, promising pitchers. Michael Kopech, injured at the start of the season, features an electric fastball and has made two starts for advanced Class A Salem (nine innings, five hits, no runs, four walks and 14 strikeouts).

The Red Sox also reportedly agreed to a deal with their first-round draft pick, high school pitcher Jason Groome, on a $3.65 million bonus.

“That helps,” Dombrowski said. “Gives us some more quality guys. Plus, the guys on our big league club who will be there a while.

“You never have enough pitching.”