As New York’s 152 municipal unions line up to press Mayor Bill de Blasio for raises and back pay, his administration and the powerful teachers’ union are reaching the final stages of a largely overlooked, drawn-out battle that could prove enormously expensive to the city — potentially putting at risk its ability to balance the budget.

The union is seeking $3.4 billion in retroactive pay, and fiscal experts say there is a realistic chance it could win.

The fight has its roots in something akin to a game of musical chairs, in which the teachers’ union was left without a seat. But the dispute could end up making it harder for other city unions to win the raises they have been agitating for after several years of working with expired contracts.

In the last round of municipal labor negotiations, most city unions received 4 percent pay increases for 2009 and 2010, and in the current dispute the United Federation of Teachers is demanding the same raises.