Former Knicks coach Mike D’Antoni admitted to the worst-kept secret of his departure — he resigned on March 14, 2012, because of Carmelo Anthony.

On the day of his resignation, The Post ran a back-page story, citing a source, that Anthony didn’t want to remain a Knick at the trade deadline if he knew D’Antoni would return next season. D’Antoni resigned later that afternoon.

According to a new ESPN Magazine profile on D’Antoni and his wife, Laurel, D’Antoni didn’t want to remain with the Knicks because of Anthony’s reported ultimatum.

“I just went in and quit,” D’Antoni told the magazine.

Anthony was bothered by several matters, including the coach’s favoritism of Jeremy Lin, who was running the coach’s speed-ball offense. Now Anthony is fighting another power struggle with Phil Jackson over the triangle.

Meanwhile, D’Antoni is a leading candidate to win the NBA’s 2017 Coach of the Year Award and was two victories away, entering Tuesday’s game with the Spurs, from leading the Rockets to the Western Conference finals with much of the league copying his 3-point-reliant, sprint attack.