The Transbay Joint Powers Authority is responsible for what likely will be millions of dollars in legal bills racked up by the developers of the Millennium Tower as they defend themselves against claims that they’re responsible for the building’s sinking and tilting.

In a ruling handed down by San Francisco Superior Court Judge Curtis Karnow late Thursday, the joint powers agency, which built the recently opened Transbay Transit Center next to the luxury high-rise, has to pay for Millennium Partners’ legal bills because of an agreement the two sides struck nearly 10 years ago.

Before the agency started building the transit center, it entered into an easement agreement with Millennium Partners. The agreement allowed the agency to use part of Millennium’s property for equipment to monitor conditions during the transit center’s construction.

As part of that agreement, the agency agreed to pay the legal costs of defending the developer against any lawsuits that claimed damage to Millennium Tower. The agreement was struck years before it became apparent the tower was sinking and tilting.

Millennium Partners, and the business entity it set up to build the tower, Mission Street Development, are being sued by the tower’s homeowners association, which wants to hold the developer responsible for the building’s structural problems.

Karnow’s ruling makes it clear that the joint powers agency has to make good on its promise to pay the developer’s legal bills in that case.

The agency claims that the developer’s building methods are the cause of the sinking and tilting. Millennium Partners counters that construction of the nearby transit center weakened the soil where the tower’s support structures are by dewatering the soil.

“We are pleased with the court’s order holding the (joint powers agency) responsible for its legal obligations to the Millennium Tower and to defend its developer ... from claims arising from (the agency’s) actions, said P.J. Johnston, a spokesman for Millennium Partners.

Dominic Fracassa is a San Francisco Chronicle staff writer. Email: dfracassa@sfchronicle.com Twitter: @dominicfracassa