Follow CBSMIAMI.COM: Facebook | Twitter

WEST PALM BEACH (CBSMiami/AP) — The doctor charged with corruption alongside New Jersey Sen. Bob Menendez, after more than 11 weeks behind bars, will be released under a bond agreement reached Thursday.

READ MORE: New Travel Restrictions In Place, Dow Drops 905 Points Over New COVID Variant Concerns

U.S. Magistrate Judge James Hopkins approved an $18 million bond package for Dr. Salomon Melgen. Melgen will likely be released later Thursday.

Defense attorneys finalized the terms of the release with prosecutors after heated debate spaced over numerous hearings, allowing for him to await trial under home detention with electronic monitoring.

“We did it!” defense attorney Matthew Menchel told U.S. Magistrate Judge James Hopkins at the start of the hearing. “We have an agreed order, your honor.”

Melgen’s family and friends hugged outside the courtroom, buoyant about the eye surgeon’s impending release. He is to be housed in a family apartment, not the sprawling home that had been his primary residence, because its waterfront access and dock were eyed by prosecutors as a gateway to him fleeing.

READ MORE: Black Friday Shoppers Out Early Hoping To Score Deals

Hopkins, too, repeatedly expressed fear Melgen could flee to his native Dominican Republic and initially ordered the doctor held until trial. He was later overruled by a district judge.

Menchel said his client was “excited about getting out” and “has not been broken by this experience.”

“We are obviously pleased that Dr. Melgen is being released today, and we look forward now to addressing the merits of the case and having our day in court,” he said.

The sweeping indictment against Melgen in Florida is separate from another federal case he faces with Menendez in New Jersey. In the Florida case, he is accused of an elaborate scheme of falsely diagnosing patients with eye conditions to bill Medicare for costly treatments. In the New Jersey case, he is accused of trading favors with Menendez to intervene in disputes with Medicare and other matters.

Both men have pleaded not guilty. Menendez is not charged in the Florida case.

MORE NEWS: Cold Fronts Bring More Than Just Cool Dry Air To South Florida

(TM and © Copyright 2015 CBS Radio Inc. and its relevant subsidiaries. CBS RADIO and EYE Logo TM and Copyright 2013 CBS Broadcasting Inc. Used under license. All Rights Reserved. This material may not be published, broadcast, rewritten, or redistributed. The Associated Press contributed to this report.)