The District’s bid to win more spending freedom from Congress through a ballot referendum is not legally permissible, a federal judge ruled Monday, dealing a setback to officials who argued that voters had the power to amend the city’s charter and change its relationship with overseers on Capitol Hill.

In a 47-page opinion, U.S. District Judge Emmet G. Sullivan ­acknowledged “extraordinarily powerful” policy arguments in favor of granting the District government more latitude in spending locally raised funds without a congressional appropriation.

But he said that only Congress, not the courts, could make that change.

“As a native Washingtonian, the Court is deeply moved by Plaintiff’s argument that the people of the District are entitled to the right to spend their own, local funds,” Sullivan wrote. “Nevertheless, the Court is powerless to provide a legal remedy and cannot implement budget autonomy for the District. . . . Congress has plenary authority over the District, and it is the only entity that can provide budget autonomy.”

The courts have, over the years, been generally unwilling to expand the political rights of the District and its residents, consistently ruling that Congress’s power over the capital city is near-absolute under the Constitution.

A 1998 lawsuit seeking to grant D.C. residents congressional voting rights was unsuccessful, as was a 2003 suit seeking permission to levy a “commuter tax” on non-District residents working in the city.

In each case, judges found that the provision in Article I of the Constitution granting Congress power to “exercise exclusive Legislation in all Cases whatsoever” over the District trumps other constitutional claims.

Officials and advocates who backed the new legal approach to gaining budget autonomy, how­ever, argued that Congress had already granted the District ability to do so — through the amendment process included in the 1973 Home Rule Charter.

The D.C. Council voted unanimously to adopt such an amendment and put it before District voters, who approved it overwhelmingly in April 2012.

But the amendment encountered doubts, most prominently from D.C. Attorney General Irvin B. Nathan, who opined that it was “patently” illegal and could lead to serious consequences for the city and its employees. Those consequences, he said, could include litigation from prospective contractors challenging the city’s spending authority or prosecution of officials for violating laws against spending government funds without authorization.

When Mayor Vincent C. Gray (D) and the District’s chief financial officer, Jeffrey S. DeWitt, each said this year they would refuse to abide by the charter amendment, following Nathan’s advice, the council sued, putting the measure’s fate in Sullivan’s hands.

Nathan personally argued his position on behalf of Gray and DeWitt in court last week, characterizing the council’s legal arguments as “nonsense” and a search for a “loophole” in the charter.

The council’s pro bono attorneys argued that the amendment was permissible under a close reading of the Home Rule Act and that Congress had permanently appropriated the city’s local budget when it passed the original charter.

Lawyer Karen L. Dunn told Sullivan that while there were “political and practical reasons” why the referendum strategy was not pursued previously, there were no legal obstacles to doing so.

Sullivan, after hearing oral arguments Wednesday, hinted he was unsure he’d be able to adopt the council’s reasoning in support of the amendment. “It may well be that the court is powerless to sanction this,” he said.

Hours after his decision came down Monday, the council filed notice it would appeal. “I continue to believe there is strong justification for the law that we passed,” Council Chairman Phil Mendelson (D) said, noting that the amendment passed a congressional review period without action.

V. David Zvenyach, the council’s chief attorney, said he and the other attorneys arguing the case “have complete confidence in our legal arguments.”

“The case presents novel legal questions of statutory interpretation and local constitutional analysis, and we believe Judge Sullivan’s opinion fails to give proper effect to the charter-amendment process set forth by Congress,” he said.

But it is unlikely the appeal will be resolved before the city is set to pass its 2015 budget, and Zven­yach told members and staff Monday to handle its passage as though the budget autonomy law were not in place.

Gray called Monday’s decision “bittersweet,” given his long-standing and outspoken support for greater independence from Congress. “However, given the concerns I have continually expressed, I’m not surprised by the ruling,” he said.

The effort to secure budget ­autonomy through a charter amendment came after Gray-backed attempts to change it through congressional legislation were stymied by Capitol Hill politicking, including efforts by Capitol Hill Republicans to attach policy riders to the bill.

Eleanor Holmes Norton, the District’s non-voting House delegate, said Sullivan’s decision would “add new urgency ” to her legislative efforts. But she expressed limited optimism that a measure could move through the House in the near future.

“I cannot get a budget autonomy bill to the floor on my own,” she said.

While some prominent Republicans have backed the District, including Majority Leader Eric Cantor (Va.) and Oversight and Government Reform Committee Chairman Darrell Issa (Calif.), political obstacles remain — including a connection to national abortion politics.

The National Right to Life Committee reiterated Monday that it opposes any D.C. budget autonomy bill that does not include a permanent ban on government funding for abortions — a compromise that city leaders have previously rejected.

The committee hailed Sullivan’s ruling in a statement Monday, calling the charter amendment “a brazen attempt to pull off a hijacking of federally controlled funds, behind a dense smokescreen of political polemic.”