The city yesterday handed over two long-shuttered Brooklyn firehouses in growing neighborhoods to nonprofit groups – ending all hope that community activists and the firefighters union had of reopening them.

Uniformed Firefighters Association spokesman Tom Butler said turning over the ex-firehouses at 299 DeGraw St. in Cobble Hill and 134 Wythe St. in Williamsburg imperils residents.

“Anything less than their reopening fails to protect these communities,” he said.

But the Economic Development Corp. tabbed the Brooklyn Philharmonic for a $2.6 million makeover of the DeGraw Street facility as its new music center.

The other 19th-century ex-firehouse is slated for a $1.3 million conversion by the People’s Firehouse Inc. and Neighborhood Allied for Good Growth into the Northside Town Hall Community Center.