Two people have been pulled from debris after a building suddenly collapsed in a Sydney inner-city suburb.

The men, aged in their 30s and 60s, were in a serious condition after being transported to hospital, Ambulance NSW said on Monday.

The roof and wall of the building in Wattle Street, Ultimo caved in about 11am on Monday, causing debris to fall on to the street and a neighbouring Shell petrol station.

Piles of large bricks were strewn on top of one another and the destroyed roof damaged nearby parked vehicles.

Another five people were assessed by ambulance personnel and released without further treatment.

“A portion of that building has collapsed, and some of the debris has come down and fallen on some cars parked within the service station area,” the Fire and Rescue NSW acting superintendent Peter Murray said.

The building was still under construction.

Urban search and rescue firefighters were at the scene, with police clearing the area and evacuating workers on the construction site.

Evacuations of surrounding buildings also took place and police urged the public to stay away from the area.