The Wal-Mart at First and H streets NW D.C. (Photo by J. Lawler Duggan/For Capital Business)

More than a dozen community groups filed a complaint with the Internal Revenue Service Monday alleging that the Walmart Foundation violated its tax-exempt status by using charitable funds to advance the retailer’s entrance into urban markets including Washington.

The 22-page complaint, addressed to IRS Commissioner John Koskinen, details the retailer’s marketing and lobbying activities as it sought approval to open stores in New York City, Boston, Chicago, Los Angeles and other cities.

The groups allege that the foundation is completely controlled by the company and that it “appears to target its donations and influence its grantees primarily to assist Walmart to achieve those expansion goals, ultimately providing Walmart more than an incidental benefit. Walmart Foundation’s activities are impermissible under the Code.”

The foundation is registered with the IRS as a 501(c)3 charitable organization, a status carries that prohibitions against operating in the sole interest of private individuals or entities.

Tricia Moriarty, director of global responsibility communications for Wal-Mart, said the foundation focuses its giving on areas such as hunger, veterans and disaster relief.

“We provide support for these and other important causes in communities across the U.S. and around the world, not just to particular areas or cities, and it’s unfortunate to see criticism of the Foundation’s charitable giving,” she said in a statement.  “The Walmart Foundation takes the Internal Revenue Code and regulations very seriously and the allegations made have no merit.”

The company said it and its foundation gave $1.4 billion in cash and in-kind contributions during the fiscal year ending Jan. 31. In its funding guidelines, the foundation explicitly states that donations cannot be made to any program that “directly benefit Wal-Mart Stores, Inc. in any way ( e.g. driving customer traffic to stores, purchasing only Walmart product or gift cards, supplying candidates for Walmart employment etc.)”

But signors of the complaint, including groups that joined organized labor in batting the retailer’s efforts to open urban stores, outline instances in which the foundation dramatically increased charitable giving to cities and neighborhoods while it was simultaneously seeking approval to open stores there.

In some cases, they say the foundation gives grants to organizations that might otherwise oppose the company’s stores, advertises charitable donations as a benefit of allowing stores to open and encourages grantees to support the company’s efforts to open stores.

During the run-up to opening its locations in previously untapped urban markets, the company sometimes hired lobbyists, bought advertising and negotiated details of their stores with elected officials.

In the District, more than two years of debate over the retailer’s affect on wages, employment practices and small businesses predated the company’s first two stores, which opened in 2013.

During that time the Walmart Foundation gave grants to groups including D.C. Hunger Solutions and the Greater Washington Urban League. Leaders at some Washington charitable groups that received grant money sometimes declined to comment to reporters about whether they felt the company ought to be allowed to open stores.

The talks resulted in a community benefits agreement in which the company committed to creating job training programs, hiring minority-owned firms for construction work and pledging not to sell guns or ammunition. The agreement also includes a commitment to make $21 million in “charitable partnerships” over the next seven years. (The agreement with the District can be read here.)

[Related: Wal-Mart agrees to fund job training programs, open hiring centers in deal with District officials]

One of the primary groups opposing the company’s efforts locally, D.C. Jobs with Justice, is a signor of the IRS complaint. Other groups joining the complaint include New York Communities for Change and South of Market Community Action Network, of San Francisco

Wal-Mart opened its first two D.C. stores, on Georgia Ave. NW and H Street NW, in December 2013. Two other stores, in Fort Totten and on East Capitol Street, are under construction, with another store expected to open at Skyland Town Center in Southeast.

This story has been updated to include a response from Wal-Mart and to remove a reference to the Historical Society of Washington D.C. The historical society hosted an event supported by the Walmart Foundation; it was not a direct grantee, as previously suggested.

Follow Jonathan O’Connell on Twitter: @oconnellpostbiz