Unionized Safeway and Giant Food employees voted Tuesday to overwhelmingly approve a contract with the area’s two largest grocery chains.

The three-year agreement, which continues to provide health-care benefits and pensions to area workers, comes after months of contentious debate. The previous contract, which expired Oct. 31, was extended twice as the United Food & Commercial Workers negotiated with Safeway and Giant over health insurance, holiday pay and wage increases.

In the end, though, both parties say they are satisfied.

“This is one of the best retail food contracts in the country,” Mark P. Federici, president of UFCW Local 400, said in a statement. “Unlike many other agreements, our members will keep their current health-care benefits and won’t be forced onto the inferior plans offered through the [Affordable Care Act’s] health care exchanges.”

On average, employees will receive an additional $3.35 per hour in wages and benefits over the next three years, with a 35-cent-per-hour raise backdated to November, according to the union. Employees will receive another 35-cent raise next November and an additional 30 cents in November 2015.

The contract is one of a few in the retail food industry that continues to provide health-care coverage for all current employees and most future employees, Federici said. Safeway and Giant — which racked up a combined $6.41 billion in area sales last year — also agreed to time-and-a-half pay on Sundays and holidays.

“Throughout negotiations, our goal was to reach fair and reasonable contracts that respect our legacy and honor our associates’ contributions, while also recognizing our competitive realities,” Jamie Miller, a spokesman for Giant of Landover, said in a statement.

But the process wasn’t always amicable. After more than six weeks of talks, members of United Food & Commercial Workers Local 400 in November voted to authorize a strike against Giant and Safeway if the two sides failed to agree on a new contract.

“We’ve never had negotiations as tough as these, with two contract extensions,” said Michelle Hepner, a member of the bargaining team who works for Giant in Stafford.

The grocery stores had proposed eliminating health-care benefits for part-time employees and workers’ spouses, as well as doing away with Sunday and holiday pay, according to a union statement.

The agreement, which covers 17,000 workers, took effect retroactively as of Nov. 1.

The contract “continues to provide our employees with excellent wages and benefits while also allowing Safeway to remain competitive in the local retail food market,” said Brian Baer, Eastern Division President for Pleasanton, Calif.-based Safeway.