The abrupt announcement that the nation's largest city may have to lay off 15,000 workers to fix a soured economy has put union leaders on a fiery collision course with the mayor they helped elect in a tight race.

Mayor David N. Dinkins says 15,000 workers may get pink slips, putting New York with other Northeastern cities that are letting workers go as the economy nosedives.New York's proposed layoffs and other agency reductions would cut $800 million from an expected budget deficit in fiscal 1992 of $1.4 billion.

The mayor also ordered an immediate freeze on hiring and merit raises, hoping to save another $115 million in payroll costs.

But the announcement elicited fire and pain from the unions that helped put Dinkins over the top last November and made him the city's first black mayor. The outcry came because Dinkins had not consulted his work-force allies.

"The mayor has declared war on the unions in the city. He has spit in the eye of public employees through this unilateral action," said Barry Feinstein, president of Teamsters Local 237, which has about 12,000 city workers.

For months, New York has been fighting to get to the core of its money problems. On top of a $1.8 billion budget gap for this fiscal year, the Democratic mayor is projecting $1.4 million gap for the fiscal year starting next July.

Dinkins has taken repeated media hits over the length of time he takes to respond to pressing problems.

The city faced an even worse budget crunch in 1975 when it nearly went bankrupt and laid off about 25,000 workers.

This time, New York joins New Haven, Conn.; Boston; Philadelphia; Trenton, N.J.; and Baltimore in using layoffs to balance the budget.