Wal-Mart has agreed to fund job-training programs, open hiring centers and make $21 million in charitable contributions in the District in a package of community benefits as the retailer prepares to open several stores in the city.

In the deal, the chain will seek small- and minority-owned businesses in the District for construction of its stores; create and fund training programs aimed at populations suffering from high unemployment rates; and open hiring centers in the wards where the chain opens stores. The donations will fund hunger relief, health programs, education and job-training programs, the retailer and city officials said Tuesday.

The chain also agreed not to sell guns or ammunition and to install bike-sharing stations and bike racks at its D.C. stores — features that will distinguish the new stores from many of its others across the country. Wal-Mart officials said the stores will create 1,800 jobs and offer fresh groceries in underserved areas.

The deal comes after six months of on-and-off negotiations between representatives of the chain and city officials. Mayor Vincent C. Gray (D), who successfully pushed the chain to plan a store for Skyland Town Center in Southeast, said in a news release that the agreement “represents an unprecedented, citywide commitment from a retailer that is already poised to help create more than 1,800 permanent jobs in our city.”

“Wal-Mart is showing what it means to be a good corporate neighbor, and I encourage other firms interested in doing business in the District of Columbia to show a similar level of commitment to our residents,” he said.

Wal-Mart spokesman Steven Restivo said it was the most broad-reaching agreement to which the company had committed, topping a similar deal it agreed to in Chicago last year. “The mayor characterized it as unprecedented, and I think that is accurate for a number of reasons,” Restivo said.

The announcement did little, however, to temper the concerns of grass-roots organizations and unions that opposed Wal-Mart’s entry into the District without an enforceable set of requirements, as the document is not legally binding and does not contain any penalties if Wal-Mart fails to fulfill its promises.

In the five-page agreement, Wal-Mart says it will try to use small- and minority-owned D.C. companies for 35 percent of subcontracting construction work, provide space to local retailers within the stores “where opportunities exist,” and meet quarterly with residents and business owners near each of its locations. Workers will earn, according to the agreement, “competitive market salaries compared to those offered by competitors.”

Tuesday’s announcement comes less than a week after Wal-Mart announced two more sites where it plans to open stores, at Skyland and near the Fort Totten Metro station in Northeast. A year ago, the company announced plans for stores at a former car dealership on Georgia Avenue NW in Ward 4; at East Capitol and 58th streets in Ward 7; at New York Avenue and Bladensburg Road NE in Ward 5; and as part of a new mixed-use development on New Jersey Avenue NW in Ward 6. It also laid out rapid expansion plans in the suburbs, plotting stores in Tysons Corner, Rockville, Aspen Hill and Oxon Hill.

Wal-Mart’s plans for the District require little from the city, as the company did not seek subsidies as other retailers have. But the chain has long endured criticism and questions over its salaries and employment practices. Local opponents of the company also have staged a string of protests, asking that the company be required to pay higher wages and hire higher specific numbers of D.C. residents.

D.C. Council Chairman Kwame R. Brown (D) said the mayor had “put forth his best effort” to reach a deal that was suitable to residents, particularly given how little the chain needed from the city. “I know this was not a light lift to work this agreement through with a company that didn’t have to agree to something in the first place,” he said.

But Respect D.C., a coalition of activists that collected 3,000 signatures requesting that the store sign a binding agreement, called the Wal-Mart deal a “sham benefits agreement” and a “backroom deal.”

Mackenzie Baris, lead organizer for the not-for-profit DC Jobs With Justice, which has coordinated protests of Wal-Mart’s plans, said the coalition considered the document more of “a statement from Wal-Mart about their intentions.”

“It is in writing and it is signed, but it is not a binding document of any kind,” Baris said.

Victor L. Hoskins, deputy mayor for planning and economic development, said that Wal-Mart had already begun to meet its commitments and that he believed the city could hold the company to its promises without a legal document.

“This is a community that makes people accountable,” he said. “So I am fully confident that between the citizens and the city government, we are going to make them accountable. I am confident of that.”

Still, Baris said she planned to press the D.C. Council to hold hearings on legislation that could slow Wal-Mart’s march. “We continue to believe that there needs to be an enforceable community benefits agreement,” she said.