NEW YORK CITY — A union representing Broadway musicians reached a tentative labor agreement with theater owners on Thursday.

The American Federation of Musicians Local 802, represents 1,200 musicians, and had threatened to strike if they didn’t have a new agreement by Thursday morning — meaning more than 20 shows would be shut down.

“This three-year agreement provides meaningful wage and health benefit increases that will preserve crucial access to healthcare for our musicians while maintaining the strong contract protections that empower musicians to build a steady career on Broadway,” the union said in a statement.

Twenty-three shows would have been affected by a potential strike, including “Hamilton” and “The Lion King.”

This is the second Broadway union deal in less than a week. The Actors’ Equity Association reached a new three-year agreement with producers over the weekend.

The Actors’ Equity contract expired on Sept. 28 and the musicians union contract expired on Aug. 31.

The unions had argued that Broadway producers could afford to increase pay and offer better benefits for musicians and actors.

The last Broadway strike lasted 19 days in 2007.