A federal judge signaled Thursday that he won’t allow construction on Maryland’s Purple Line to begin while a lawsuit seeking to block the project is pending, saying any costs the state might incur for further delays would be “self-inflicted.”

At a hearing, U.S. District Judge Richard J. Leon castigated Maryland officials for signing a $5.6 billion contract for the project in April 2016, before he had decided the case, and without a financial “escape clause” in case the state lost the lawsuit.

Maryland officials have said legal delays are costing the state more than $13 million a month and could leave taxpayers with $800 million in costs and contract fees if the project is eventually canceled.

Leon showed more disbelief than sympathy.

State officials “took the risk to the state of Maryland and the taxpayers of Maryland without an escape clause if the litigation didn’t go the way it thought,” Leon told Albert Ferlo, an attorney for Perkins Coie, who represented the Maryland Transit Administration. “Why should the court . . . bail you out of a gamble that you took?”

Leon noted that the team of companies contracted to build and operate the 16-mile light-rail line, Purple Line Transit Partners, ensured it would still get paid if the project was significantly delayed or canceled. Maryland officials, he said, had “rolled the dice” by committing millions in state money before seeing whether he would dismiss the lawsuit.

Leon said he would issue a written opinion in coming days on the state’s motion asking that he restore the project’s environmental approval while it appeals his earlier ruling that its environmental study was insufficient.

The state needs a judge to reinstate that approval before it can begin construction and, more important, try to secure $900 million in federal grants. Leon revoked that approval in August when he ordered the state to redo the Purple Line’s ridership projections to account for Metro’s falling ridership and safety problems.

Leon said the state should not get access to the federal funding until the environmental impact study is redone, because it might show that a less-expensive project would serve the state’s desire for better east-west transit in the Washington suburbs.

“Perhaps under a more modest approach, based on the Metro situation, it would be $400 million or $500 million, which would protect federal taxpayers,” Leon said.

If Leon rejects the state’s motion, the state is expected to ask the U.S. Court of Appeals for the D.C. Circuit to reinstate the environmental approval while it considers the state’s appeal.

The judge said Maryland had caused its own delays by continuing to fight his ruling to update the ridership projections rather than simply do it.

“It might have been done by now,” Leon said, “but instead you chose the litigation strategy.”

Ferlo, the attorney for the state, said the federal law at the center of the lawsuit requires the government to take a “hard look” at a project’s potential environmental impacts, but does not regulate how much money should be allotted to it.

He said the state would soon run out of money to continue paying for pre-construction work in anticipation of being reimbursed with the federal funds. Maryland Transportation Secretary Pete K. Rahn recently scaled back work on the project, saying the state needed to cut costs while the legal case continues.

“There’s little money left for the state to continue on doing what it’s been doing,” Ferlo told the judge.

Ferlo argued again that the Federal Transit Administration had already determined that Purple Line ridership would be “more than robust” and worth a light-rail line, even if no Metro riders used the Purple Line. Metro passengers are expected to make up 27 percent of the Purple Line’s ridership.

Even so, he said, federal law requires agencies to consider only “reasonable or foreseeable” impacts.

Even if Metro’s ridership decline continues, Ferlo told Leon, “Metro going away is not going to happen.”

Eric Glitzenstein, an attorney for Purple Line opponents who filed the 2014 lawsuit, said the state shouldn’t be allowed to begin cutting trees and destroying wildlife habitat until it completes the court-ordered ridership analysis. He told Leon that Maryland allowed its contractor to start pre-construction work on the line two days after the judge raised concerns about Metro ridership during a court hearing last June.

“They still went ahead and decided to spend hundreds of millions of dollars on a project that the court had already said had serious legal problems,” Glitzenstein said.

Erin Henson, spokeswoman for the Maryland Department of Transportation, said that the state disagreed with the judge.

“We don’t believe Judge Leon will have the last word on this incredibly important project for the Washington region and the State of Maryland,” Henson said in an email.