Mayor Bill de Blasio and New York’s main teachers’ union are on the verge of announcing a deal to settle a nearly five-year-long labor dispute in which the teachers’ union has sought more than $3 billion in back pay from the city.

Two officials said a deal could be announced at City Hall on Thursday, with one official involved in the talks saying the two sides would announce a nine-year contract.

Mayor de Blasio has cleared his schedule for Thursday, these officials said, postponing a long-planned major announcement about his ambitious affordable housing plan.

One teachers’ union official said: “We’re just finalizing the language. It could be very soon.”

The contract talks for the United Federation of Teachers, which represents more than 100,000 teachers and other school employees, had been bogged down for years: Mayor Michael R. Bloomberg had declined to grant any retroactive raises. The union was demanding $3.4 billion in back pay, saying it deserved the same 4 percent raises for 2009 and 2010 that most other city unions had received. The teachers’ union has been without a contract since November 2009.