Legal obstacles are now cleared to allow some crew members of the cargo ship that destroyed the Francis Scott Key Bridge to return home after 12 weeks stuck aboard the vessel.

A court hearing Thursday morning confirmed that the army of lawyers involved in litigation surrounding the crash reached an agreement late Wednesday that will permit some members of the crew to leave the United States and be deposed at a later date.

The hearing was scheduled originally in response to emergency motions from the city of Baltimore and another party, both of which have claims against the cargo ship Dali and raised concerns after learning this week that crew members could be leaving the country as soon as Thursday.

The ship’s operator is bringing on a replacement crew, which occurs periodically with crews in the industry, before the Dali is moved to Norfolk, Virginia, for more repairs as early as next week.

Both parties ultimately withdrew their motions and indicated they were able to reach an agreement: The lawyers for the ship’s owner and manager will guarantee that the crew members will appear for depositions later, possibly in London.

In all, eight crew members and two trainee cadets have been granted permission to return to their home countries, said Darrell Wilson, a spokesman for Synergy Marine Group, the vessel operator. The group includes a cook, several seamen, a fitter, an oiler and a general steward.

The exact timeline for their departure remains unclear. The remaining crew will be lodged in Baltimore for the time being, Wilson said.

Thursday’s hearing included seven government lawyers from various agencies, including the U.S. Department of Justice and the National Transportation Safety Board. None spoke at the hearing, where Senior U.S. District Judge James K. Bredar reaffirmed that an agreement had been reached and asked the lawyers to be as efficient as possible in the future.

Thursday’s hearing could have been avoided entirely if the lawyers for one of the claimants had withdrawn their emergency motion Wednesday night instead of Thursday morning, said Bredar, addressing attorneys William H. “Billy” Murphy Jr. and Jason P. Foster.

“How are we going to conduct this very complex and potentially lengthy proceeding in the coming months and years?” Bredar asked. “My aspiration is that we’re going to do so efficiently and with every lawyer bringing their A-game and being conscious of the fact that the actions they take or don’t take have consequences.”

After the hearing, Murphy said he was satisfied the emergency was resolved.

“We’re happy that we were able to file the emergency motion and cause the agreement to be made,” Murphy said.

His team filed the withdrawal as quickly as they could, he said, adding that they were still in negotiations as late as this morning.

Murphy’s client in the litigation, Damon A. Davis, has not yet filed his claim against the Dali. Murphy declined to describe his client’s connection to the case Thursday, saying Davis is suffering from post-traumatic stress disorder and does not want publicity.

The legal dispute began Tuesday when an attorney for the ship’s owner and manager, William Bennett, emailed claimants and informed them that eight crew members would be allowed to leave as early as Thursday.

The Coast Guard declined a request to help secure crew members temporary parole through Customs and Border Patrol, Bennett wrote, so the men would need to go directly to the airport from the vessel.

Claimants’ attorneys objected, noting that they had been promised plenty of notice before crew members began to return home. Their emergency motions triggered Thursday’s hearing, though the deal was reached before Bredar could take the bench.

The final agreement included the two trainees, whose names were not on the original list of crew members granted permission to leave. The ship’s lawyers also agreed to turn over personnel files and other documents about the crew members.

The Dali struck the Key Bridge early on the morning of March 26, collapsing the span into the Patapsco River and killing six members of a crew who were doing road work on the bridge. The accident closed the Port of Baltimore to all vessel traffic for weeks. It wasn’t fully reopened until this month.

The ship’s owner and manager, both companies based in Singapore, quickly filed a limitation of liability action in federal court aimed at capping the amount of damages they could be forced to pay at about $43 million, roughly the salvage value of the Dali and its cargo. Parties who believe they may be entitled to damages stemming from the crash have until September to file claims against the ship.

The Dali remained pinned under the Key Bridge until last month, when it was refloated and moved to Seagirt Marine Terminal. The massive ship and its crew, who are from India and Sri Lanka, have remained there since, as workers removed more bridge debris from the ship’s bow.