More than half the members of the City Council have fired off a letter to Walmart demanding that it stop making millions in charitable contributions to local groups here.

Twenty-six of the 51 members of the Council charged in the letter that the world’s biggest retailer’s support of local causes is a cynical ploy to enter the market here.

“We know how desperate you are to find a foothold in New York City to buy influence and support here,” says the letter, obtained by The Post and addressed to Walmart and the Walton Family Foundation.

“Stop spending your dangerous dollars in our city,” the testy letter demands. “That’s right: this is a cease-and-desist letter.”

Last week, Walmart announced that it distributed $3 million last year to charities here, including $1 million to the New York Women’s Foundation, which offers job training, and $30,000 to Bailey House, which distributes groceries to low-income residents.

Walmart, which has been thwarted by union-backed opposition for more than a decade, said the handouts “can make a difference on big issues like hunger relief and career development.”

The retail giant said its business agenda “aligns with supporting the local organizations that are important to our customers and associates.”

But Council Speaker Melissa Mark-Viverito called the donations “toxic money,” and accused Walmart of waging a “cynical public-relations campaign that disguises Walmart’s backwards anti-job agenda.”

Sources said activists will stage a demonstration Wednesday outside City Hall, tearing up giant, mocked-up, Ed McMahon-style checks from Walmart to prove their point.

A key bone of contention is the Waltons’ support of New York City charter schools. Since 2004, the Walton Family Foundation has funneled $16 million into the cause, including the DREAM Charter School, Village Academies and the Success Academy founded by Eva Moskowitz.

“We’re proud of the work they’re doing to transform the public-education landscape and proud to have played a small part in their success,” Walton Family Foundation spokeswoman Daphne Davis Moore said.

Walmart has raised eyebrows with its New York political contributions before.

As reported by The Post, former Brooklyn Borough President Marty Markowitz appeared to soften his attitude toward the company in 2011 after the retailer donated $150,000 to his summer Martin Luther King Jr. concert series.

In March, Walmart officials signaled a temporary retreat from efforts to open a New York City store after setbacks at a site in Brooklyn off the Belt Parkway.