BOSTON — J.D. Martinez wants to thank the Astros — not get back at them — for releasing him when he was struggling to make himself into a star.

The Red Sox slugger credits his growing pains in Houston for teaching him “how to fail,” a lesson he credits with transforming him into an MVP candidate who helped the Red Sox win a franchise-record 108 games and reach the AL Championship Series against his former team.

“My failures in Houston is what made me who I am,” Martinez said Friday, a day before the Astros and Red Sox open the best-of-seven series. “There’s really no animosity there. In a sense they did me a favor by allowing me to leave and play on another team.”

It will be the second straight year the Red Sox and Astros meet in the postseason — last year it was the ALDS — and the second straight year that aces Chris Sale will go against Justin Verlander in the opener.

The biggest difference this time: the Red Sox have Martinez on their side.

And the Astros could have.

Martinez made his big-league debut for the Astros in 2011, driving in 28 runs in his first full month in the majors.

After playing part time the next two years — hitting 18 homers with 91 RBIs in 199 games — he was 26 years old and batting .167 in the spring of 2014 when the Astros released him, preferring to give the at-bats to top prospect George Springer.

Martinez landed with the Tigers that season and by 2015 he was an All-Star, hitting 38 homers with 102 RBIs.

He hit 45 homers last year, when he was traded from the Tigers to Diamondbacks and was 14th in MVP voting despite playing just 62 games in the NL.

“I always believed he’s going to be the player he is right now,” said Astros second baseman Jose Altuve, the reigning AL MVP, who came up through the minors with Martinez. “He got a couple of tough years with us in the big leagues. But I think the best thing that happened to him was going to the Tigers and becoming the player that he is.

Verlander was Martinez’s teammate in Detroit and said he was “there from the moment he turned his career around.”

“He went and completely revamped his swing that offseason, and saw immediate dividends,” Verlander said. “(He) never stopped hitting. Seeing somebody like that who works so hard and turned their career around to where he’s at now, as a fellow player, and you respect it and I’m happy for him. I really am.”