Workers at a Giant Food warehouse in Maryland ratified an agreement with the operator that eliminates nearly half of the staff, ending months of contentious negotiations in which the union feared that the site would be shuttered.

Teamsters Local 730, which represents 430 workers at the dry-groceries warehouse in Jessup, accepted a 40 percent reduction in staff, with the assurance that employees would be offered jobs in other parts of the company or buyouts. The vote was 241 to 19.

“You can never be happy when you have to make concessions, but with this we made the best of a bad situation,” said Ritchie Brooks, president of Teamsters Local 730.

The area’s largest supermarket chain agreed in April to have Jessup Logistics, an affiliate of C&S Wholesale Grocers, assume operations of its dry-groceries warehouse in Jessup. The operator began meeting with the union in March to negotiate the contract that was set to expire May 14.

Days after the sides began negotiating, Brooks said, officials from Jessup Logistics gave verbal notice that the plant would close, leading to protests at more than 16 Giant locations throughout the Washington area.

At one point, the International Brotherhood of Teamsters rallied outside the Hyatt Regency in the District, where the Food Marketing Institute held its annual policy meeting, attended by C&S. More than 200 labor activists gathered, including some of the 1,000 A&P supermarket workers from New Jersey who lost their jobs when C&S closed their distribution centers in February.

Under the new contract, only a fraction of the work will be shipped out. Workers will pay 25 percent of their health insurance; previously they contributed nothing to cover health care. They also agreed to a $3-an-hour pay cut. C&S did not respond to calls seeking comment.

Giant is offering displaced workers driver training, with preferential hiring rights, and bonuses to employees in the produce warehouse who retire to free up positions, according to Giant spokesman Jamie Miller.

The grocer is also leasing the facility to Jessup Logistics for less than 50 percent of the market cost to stem further layoffs. All told, Giant is saving the operator $3 million to $5 million, depending on buyouts and voluntary retirements.

In separate negotiations, Giant came to a four-year agreement with Local 730, along with Teamsters Local 639 representing drivers, for its produce warehouse in Jessup. The company agreed not to outsource the plant for three years, putting to rest one of the union’s biggest concerns.