NEW YORK — Carmelo Anthony wanted to be a Knick a few years ago, and nothing has changed now.

Anthony is staying in New York, announcing his decision Sunday in a posting titled “My City, My Heart” on his website.

“This organization has supported me and in return, I want to stay and build here with this city and my team,” Anthony said.

He explained that he owed it to himself to explore all his options as a free agent, and thanked the teams he met with for their interest.

“Through it all, my heart never wavered,” he wrote.

The Knicks can pay the All-Star forward nearly $130 million over five years, though Anthony has said he would be open to taking less than the maximum salary if it would help build a winning team.

Anthony decided four summers ago he wanted a trade from Denver to New York, and the Nuggets were finally able to accommodate him in February 2011. Anthony, who was born in Brooklyn, wrote in his posting that at that time he had dreamed of coming back of New York.

But the 30-year-old forward also wants to compete for championships, and the Knicks don’t seem ready at the moment. They went 37-45 last season, the first time in Anthony’s 11-year career he missed the postseason.

They hired Phil Jackson as president in March, and Anthony believes the 11-time champion as a coach can turn the organization into a winner.

“After three months of questions around Carmelo Anthony’s return to the NY Knicks, we are now happy to know that we have the cornerstone of what we envision as a ‘team of excellence,’” Jackson said in a statement.

“(General manager) Steve Mills and I have assured Carmelo through our conversations, that we share the vision and the determination to build this team.”

Anthony is eager to work with Jackson, who is expected to talk about Anthony’s decision on Sunday in Las Vegas, where the Knicks are practicing on an off day at the summer league.

“I am looking forward to continue my career in Orange & Blue and to work with Phil Jackson, a champion who builds championship teams,” Anthony wrote.

Anthony met with Chicago, Houston, Dallas and the Lakers after terminating the final year of his contract and becoming a free agent July 1. A few of those teams seem much closer to contending than the Knicks, but none could offer anywhere near the salary under NBA rules, which allow players to sign five-year deals with their current teams but only for four years with another.

Jackson and the Knicks made it clear how much they wanted to keep the 2012-13 NBA scoring champion, telling him in a July 3 meeting in Los Angeles that they were willing to pay him the maximum allowable salary.

Anthony took another 10 days to announce his decision, though apparently the Knicks were his preference all along.

“I will always remember this chapter in my life,” he wrote. “In the end, I am a New York Knick at heart.”