The city of Long Beach will take over daily operations of the historic Queen Mary for the first time in more than 40 years after the ship’s current operator chose to give up the lease in a sudden decision in bankruptcy court, city officials said Friday.

The move means Long Beach will have complete control of the ship and will be tasked with deciding how much to invest in critical repairs for the aging vessel. An inspection report in April determined the ship would need at least $23 million in critical repairs to remain viable in the next two years.

The Long Beach City Council on Tuesday will consider the immediate authorization of $500,000 in Tidelands Critical Infrastructure funds to begin testing and design work for safety projects. Officials said the city will work to identify other funding options to cover a minimum of $5 million in immediate repairs.

“We will be fully engaged in the preservation of this historic landmark and are incredibly grateful for this opportunity,” Mayor Robert Garcia said in a written statement.

The action comes as the current leaseholder filed a motion to reject the lease in bankruptcy court on Friday.

The ship’s operator Eagle Hospitality Trust filed for Chapter 11 bankruptcy in January with a total of more than $500 million in debt. The ship’s lease was set to go to auction but did not receive any bidders, while the city had been locked in a legal battle with former operator Urban Commons over a litany of failed lease obligations.

Among the issues, the city said Urban Commons failed to perform more than $40 million in critical repair work, resulting in “significant issues and damage” to the historic vessel. The firm also owes the city nearly $1 million in fees and unpaid rent.

Long Beach Deputy City Attorney Richard Anthony on Friday said the lease surrender does not affect the city’s damage claims against the former operator and that potential damages owed by the former operator to the city are still under consideration by the judge in bankruptcy court.

Long Beach owns the Queen Mary but for decades has leased the ship to a string of operators who have failed to make the ship profitable and plummeted into bankruptcy.

A marine survey released in 2017 found that the ship could need nearly $300 million in critical repairs to stay viable over the next several years. The city that year issued $23 million in bonds and Tidelands funds to former operator Urban Commons to fix some of the most critical repairs listed in the marine survey, but the funds ran out before many of the repairs were completed, and now, the latest report says most of the urgent structural work hasn’t even started as the ship slips into further disrepair.

The report from a city-hired naval architecture and marine engineering firm called Elliott Bay Design Group, which inspected the ship on April 28, says the vessel is vulnerable to flooding or possibly even capsizing if critical work isn’t addressed.

While the council on Tuesday will consider an emergency $500,000 in funds, the city will need significant funding to fix critical repairs including bulkhead repairs, lifeboat removal, temporary bilge pumps and the installation of an emergency generator.

The ship will remain closed to the public while the repairs are complete, officials said. The City Council at a later date will hold a study session on options and other strategies for preserving the ship.

As part of the transaction, Long Beach will also regain control of the surrounding 40-acres of property, which officials have said holds great potential for development.

“We know this is a big undertaking, and we are committed to doing right by our community who hold the Queen Mary dear in their hearts,” Councilwoman Cindy Allen, whose District 2 includes the ship, said in a written statement.

The city will also consider a $2 million contract with Evolution Hospitality, a third-party contractor that has managed the ship’s daily operations for the past decade.

Long Beach last had control of the Queen Mary in 1978, while the Port of Long Beach held ownership until 1993.

Long Beach is now exploring possibly shifting control of the Queen Mary and the surrounding land back to the city’s Harbor Commission, which oversees the Port of Long Beach.

The Queen Mary has served as a tourist attraction and hotel since it arrived in Long Beach in 1967.