WASHINGTON — A federal court ruled this month that a Montana insurer is entitled to federal compensation for subsidy payments under the Affordable Care Act that President Trump abruptly ended last October, a ruling that could reverberate through insurance markets and cost the government hundreds of millions of dollars.

At issue are payments for so-called cost-sharing reductions, discounts that enhance the value of health insurance policies purchased from the Affordable Care Act’s marketplaces by reducing deductibles, co-payments and other out-of-pocket costs for low-income consumers. President Trump ended the payments in October, one of a series of executive actions intended to undo President Barack Obama’s signature domestic achievement.

But Judge Elaine D. Kaplan of the United States Court of Federal Claims said this month that Mr. Trump’s actions violated a government promise to insurance companies participating in the health law. Although Congress never explicitly provided money for the subsidies, the court said, the government had a legal obligation to pay them.

“The statutory language clearly and unambiguously imposes an obligation” on the government to reimburse insurers for the discounts they were required to provide to low- and middle-income people, Judge Kaplan said in her decision.