A federal judge on Wednesday expressed reservations about the District’s bid to gain greater spending freedom from Congress through a voter referendum, saying he sympathized with the city’s desire for greater fiscal autonomy but had doubts about whether it could be granted through the courts.

After hearing three hours of oral arguments, U.S. District Judge Emmet G. Sullivan did not rule on the D.C. Council’s request to have the April 2013 referendum declared binding law and enforced by city officials. A decision, he said, will be issued in the coming days.

But Sullivan hinted that budget autonomy cannot ultimately be granted through the courts, saying he was “troubled” by the authority he might have to intervene. “It tugs at the heartstrings,” he said. “But the court can’t rule from the heart.”

He compared the budget autonomy case to a civil lawsuit brought in 2008 by former hostages held by Iran from 1979 to 1981, seeking monetary damages for their imprisonment. Sullivan said he had deep sympathy for the hostages but the law demanded he dismiss their case, because the treaty that secured their release had barred such litigation.

The unusual legal clash over District budget autonomy has pitted the council, which believes the referendum is binding, against Mayor Vincent C. Gray, Chief Financial Officer Jeffrey S. DeWitt and D.C. Attorney General Irvin B. Nathan, who believe it is not.

At stake is whether District officials will continue to submit their spending plan to be formally appropriated by Congress, as they have done faithfully since gaining home rule in 1975. Should the referendum be sustained, federal lawmakers would have only a passive role in approving the D.C. budget, which leaders say would allow them to more efficiently and prudently manage the city’s fiscal affairs.

The District budget is composed mainly of locally raised taxes and fees. Only a small portion of overall spending consists of special federal appropriations not also available to states, mainly for the courts and some health and education programs.

Sullivan has been asked to determine whether, more than four decades ago, Congress embedded in the Home Rule Act the ability for city voters to change the District’s budgeting procedure.

Gray (D) and DeWitt, following Nathan’s legal interpretation, say that the referendum oversteps the city’s power to amend its own charter and is thus legally void. Were city officials to budget and spend money without a congressional appropriation, it could expose the city to litigation and even criminal prosecutions, Nathan has said.

The council, adopting a legal position developed in part by D.C. voting-rights activists, says voters do have the power to amend the charter to change the budget process. Pro bono lawyers recently argued to Sullivan that Congress permanently appropriated the city’s general fund when it first granted home rule.

The case has also attracted significant outside legal attention, with five groups submitting friend-of-the-court briefs ahead of Wednesday’s arguments. Sullivan asked lawyers for both parties in the case to respond to two briefs challenging the referendum’s validity, including one from lawyers representing the U.S. House of Representatives and another from lawyers intimately involved in drafting the Home Rule Act.

The legal dispute has taken on a partisan tinge: House Republicans have previously made statements challenging the legal force of the referendum. And while the House brief was authorized by a committee that includes members of both parties, the group’s Democrats declined to support its filing.

In an unusual move, Nathan personally argued the case Wednesday for Gray and DeWitt, illustrating the high stakes of the proceeding. The council’s case was argued by lawyer Karen L. Dunn of Boies, Schiller & Flexner, who is serving pro bono alongside Brian D. Netter of Mayer Brown.

Should Sullivan find the referendum invalid, D.C. Council Chairman Phil Mendelson (D) has said an appeal is likely. If he were to find it legally sound, it is unclear how Gray or DeWitt might react. Nathan said last month that a higher court ruling “would be helpful,” but Gray has been an outspoken advocate for budget autonomy and could wave off an appeal.

A mayoral spokesman would not say what Gray would do if Sullivan rules in the council’s favor. “Unfortunately, we are confident in our opinion that [the referendum] was not legal and that we won’t need to appeal,” said Pedro Ribeiro.

But Walter Smith, executive director of the D.C. Appleseed Center, which helped develop legal arguments in favor of the referendum, said he does not expect Gray to challenge a court decision granting the city budget autonomy at long last.

“It would be against what he favors, as well as the city’s best interests, not to take yes for an answer,” Smith said.