WEST PALM BEACH, Fla. - A Florida doctor charged with corruption alongside New Jersey Sen. Bob Menendez will be released after more than 11 weeks in jail under a bond agreement reached Thursday.

U.S. Magistrate Judge James Hopkins approved an $18 million bond package for Dr. Salomon Melgen, making his release later Thursday likely. 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.

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.