Fabric nightclub is to reopen after Islington council agreed to strict new licensing conditions, including an over-19s policy and ID scanners at the entry to the venue.

The Farringdon nightclub, one of London’s most well-known venues, was stripped of its licence and faced permanent closure after the drug-related deaths of two teenagers.

However, in a court hearing on Monday, Islington council said it would accept 32 new conditions put forward by Fabric’s owners that would prevent drug abuse and allow the club to open its doors again.

The rules, set out in a 155-page document, include banning entry to anyone under 19 on main nights, more comprehensive CCTV monitoring, ID scanners and lifetime bans for anyone caught asking for drugs.

The club’s court appeal against closure was made up of 41 witness statements and included acceptance by Fabric that the police investigation was “reasonable” and that “procedures in relation to searching were insufficient, as were its procedures to prevent the consumption and dealing of drugs within the club itself”.

It was presented at Highbury magistrates court and given approval by judge Robin McPhee.

McPhee told the court: “I’m satisfied that the council and Fabric pulled together to get a set of workable conditions to prevent drug use and supply.”

Ranjit Bhose, the QC acting for Islington council, told the court it was “satisfied management understand the processes they need to make sure Fabric is safe for young clubbers”.

he court ordered that Fabric will also have to pay Islington council’s legal costs, but that will not come out of the £320,000 donated by supporters of the nightclub.

A statement from the club following its successful appeal thanked supporters, telling them: “You saved Fabric.”

It said: “We owe everything to our supporters. We really would not be here today without your unparalleled support and generosity. So many different people stepped up to put their voices to our cause, artists from all corners of the music community, fellow promoters who have put on huge events from us and clubbers from around the world who all united behind us.”

The mayor of London, Sadiq Khan, who had previously urged the council and the Met police to find a solution to Fabric’s future, welcomed the decision and said he and his newly appointed “night czar”, Amy Lame, were working to preserve London’s nightlife.

“I’m delighted that agreement has been reached and that Fabric will now reopen,” said Khan. “The issues faced by Fabric point to a wider problem of how we protect London’s night-time economy, while ensuring it is safe and enjoyable for everyone. Over the past eight years, London has lost 50% of its nightclubs and 40% of its live music venues. This decline must stop if London is to retain its status as a 24-hour city with a world-class nightlife.”

The decision to revoke Fabric’s licence came after 18-year-olds Ryan Browne and Jack Crossley died after taking ecstasy at the club on 26 June and 6 August respectively.

A covert police investigation also suggested people were openly buying and taking illegal drugs on the premises and concluded that staff should have been aware of it.

However, the decision to shut down the club, which has played host to some of the world’s most famous artists and DJs since it opened its doors in 1999, was met with criticism by thousands of people, including local MP Emily Thornberry, and more than 160,000 signed a petition against its closure.

Under the new regulations submitted to the council, the managing director of Fabric, Gary Kilby, made assurances the club would operate “to a gold standard”.