Boris Johnson has called for anti-homeless spikes outside a luxury block of London flats to be removed immediately, describing them as "ugly, self-defeating and stupid".

The mayor of London urged the owner of the private block of deluxe apartments to remove the inch-high metal studs, which triggered outrage when a picture of them was posted online at the weekend.

He tweeted on Monday: "Spikes outside Southwark housing development to deter rough sleeping are ugly, self defeating & stupid. Developer should remove them ASAP.

"We've spent £34m on the likes of 'no 2nd night out' [which aims to ensure no one spends more than one night on the streets], reaching 3/4s of rough sleepers, but must do more. Spikes are simply not the answer."

The spikes, which are thought to have been installed in the last month and have been compared to those used to keep birds away from buildings, are in a sheltered alcove opposite a hostel for homeless people with mental health problems on Southwark Bridge Road.

About 5,000 people have signed a petition calling for the spikes to be removed and several people have lodged complaints with Southwark council about the studs, which have been described by homelessness charities as inhumane.

Katharine Sacks-Jones, head of policy and campaigns at Crisis, said people "deserve better than to be moved on to the next doorway along the street. We will never tackle rough sleeping with studs in the pavement. Instead we must deal with the causes".

A spokeswoman for Southwark council said it was investigating but that there was little it could do unless there had been a breach of planning regulations.