BROOKLYN - Long Island College Hospital is safe another day after court negotiations bought some time for the facility, which has been struggling for years to keep its doors open.

A judge signed off on an agreement between SUNY Downstate and the Peebles Corporation to continue taking patients.

The cash-strapped hospital was scheduled to close on Thursday after a deal between SUNY and the initial top bidder Brooklyn Health Partners fell apart earlier this month.

The plan calls for keeping the emergency room services running until May 27. At that point, Peebles will partner with North Shore-LIJ to continue to run ER services. Ambulances, though, will not be restored until July 15.

LICH stopped sending out its own ambulances for 911 calls when it lost the potential buyer last week. FDNY units have since stepped in as a replacement.

As of right now, it's not clear what the rest of the hospital will be used for and employees are bracing themselves for layoffs.

The current agreement is temporary and a permanent deal is expected to happen in June. SUNY officials say they've had very productive conversations with the Peebles Corporation and the North Shore Long Island Jewish Health System, and are hoping to finalize a permanent health care solution for the Cobble Hill community.