Budweiser brewer Anheuser-Busch has reached a contract agreement with the Teamsters union that avoids a strike at its U.S. plants.

The union had threatened a strike at the brewer's 12 U.S. plants if an agreement on a new five-year contract wasn't reached by 11:59 p.m. EST Thursday. The Teamsters union represents 5,000 Anheuser-Busch workers who brew and package beer and even take care of the company's legendary Clydesdale horses.

But the two sides said late Wednesday they had reached a tentative agreement that boosts wages and increases vacation days and pension contributions.

''Teamsters make the beer, Teamsters make Anheuser-Busch successful and our members deserve the best contract. That is what we fought for and won today,'' Teamsters General President Sean M. O'Brien said in a statement.

Anheuser-Busch CEO Brendan Whitworth said the contract also makes significant job security commitments.

"Our people are our greatest strength, and we are incredibly pleased to have reached a tentative agreement that continues to recognize the talent, dedication, and hard work of our teams, while also positioning the company for long-term success,'' Whitworth said in a statement.

The union said the full tentative agreement will be shared with workers prior to a ratification vote, which is expected to happen next week.

The strike would have been the first in the U.S. against Anheuser-Busch since 1976.

The union said earlier this month it was angered by a company proposal that would close breweries and lay off workers.

But Anheuser-Busch is facing declining beer sales in the U.S., where drinkers are increasingly opting for spirits, hard seltzers and alcohol-free beverages.

It's also trying to win back consumers. Bud Light, its best-selling brand, faced a conservative backlash last year after it sent a commemorative can to transgender activist Dylan Mulvaney. Transgender rights supporters also deserted the brand, saying it didn't do enough to support Mulvaney.

Anheuser-Busch shipments to U.S. wholesalers dropped 13.8% last year, according to Beer Marketer's Insights. Overall, U.S. beer shipments were down 5%.

The company, part of Belgium-based Anheuser-Busch InBev, brews more than a dozen brands at its U.S. plants, including Budweiser, Bud Light, Michelob Ultra and Stella Artois.

Not all U.S. brewers have been spared strikes, however. On Wednesday, 420 Teamsters-represented workers were on their second week of a strike at a Molson Coors plant in Fort Worth, Texas.

''Molson Coors should pay close attention to the bar we've set today for brewery workers across the country,'' O'Brien said in his statement.