The ruling is another victory for the U.S. Justice Department, whose antitrust enforcement became much more aggressive during former U.S. President Barack Obama's eight years in office, which ended last week.

Obama's successor, Donald Trump, and a Republican-controlled legislature are seeking to undo much of the Affordable Care Act, better known as Obamacare. The law reshaped the U.S. healthcare industry by mandating health insurance and creating online exchanges where consumers can shop for individual policies and get subsidies.

Aetna, Humana, Anthem and Cigna had cited Obamacare as one of the main reasons their industry needed to consolidate to cope with the costs of expanding coverage. Their shares ended trading on Monday at levels that suggested that investors continued to see little chance that the two mergers would happen.

The U.S. Justice Department filed a lawsuit last July to block Aetna's acquisition of Humana and Anthem's acquisition of Cigna, arguing that the two deals would lead to higher prices.

Anthem and Cigna are still waiting for a judge to rule on whether their merger can proceed. Investors have long been skeptical that this deal can be approved, and Leerink Research analyst Ana Gupte reiterated on Monday that she expected to also see this deal blocked.

In his ruling, Judge John Bates of the U.S. District Court for the District of Columbia said the proposed deal would "substantially lessen competition" in the sale of Medicare Advantage plans in 364 counties in 21 states that the Justice Department had identified in its complaint, and on the Obamacare exchange in three Florida counties.

"We're reviewing the opinion now and giving serious consideration to an appeal after putting forward a compelling case," Aetna spokesman T.J. Crawford said. Humana did not respond to a request for comment.

Humana stands to receive a $1 billion breakup fee from Aetna should the deal be abandoned.

Jeffrey Jacobovitz, a litigator at law firm Arnall Golden Gregory LLP, said that appeals at the D.C. Circuit succeed about one-third of the time and can take a year to resolve. He added that it would be difficult, though not impossible, for Aetna to wait for Trump's new antitrust enforcers to be named and then strike a settlement to save the merger, perhaps by offering to divest more assets.

Bates dismissed Aetna's argument that there was plenty of choice for consumers because Medicare Advantage, which is managed by insurance companies, competes with traditional Medicare for the elderly and disabled, which is managed by the government.

"In that (Medicare Advantage) market, which is the primary focus of this case, the merger is presumptively unlawful - a conclusion that is strongly supported by direct evidence of head-to-head competition as well. The companies’ rebuttal arguments are not persuasive," Bates wrote in a 158-page decision.

Humana shares ended trading up 2.2 percent at $205.02, as investors brushed off the widely expected ruling. Shares of Cigna, the other health insurer to be acquired, were almost flat at $145.31

SEVERAL DEALS TORPEDOED

Several big deals were torpedoed by antitrust regulators last year, including the $35 billion merger between oil-field service groups Halliburton Co and Baker Hughes Inc and the $6 billion combination of Staples Inc and Office Depot Inc .

Bill Baer, the former head of the Justice Department's antitrust division who initiated the lawsuit to block the Aetna-Humana deal, called the decision "a strong affirmation of the role that competition plays in health insurance markets."

Doctors and hospitals had urged the Justice Department to block the deal, fearing it would erode their pricing power. Some large employers also opposed the combination.

"Today's ruling is a decisive victory for jobs, consumers, and healthcare. Mega mergers like the proposed consolidation of Aetna and Humana raise prices, lower health care quality – and kill jobs," said Senator Richard Blumenthal, a Connecticut Democrat.

Aetna had offered to sell a portfolio of about 290,000 Medicare Advantage members in 21 states to smaller peer Molina Healthcare Inc for $117 million, but that deal failed to appease Judge Bates.

"We are disappointed by the court's ruling today. However, whatever the ultimate outcome of that litigation, we remain committed to growing our Medicare Advantage product line," Molina spokeswoman Sunny Yu said.

Humana is the second-largest Medicare Advantage insurer while Aetna is the fourth, and the two compete in more than 600 counties, the government said in its complaint. Despite the adverse regulatory environment, some analysts suggested that an acquisition of Humana by someone other than Aetna was possible.

"We still suggest other potential M&A optionality exists for Humana, since nothing in the verdict seems to preclude it from possible buyers that expressed historic interest and that have less market overlap, namely Cigna and Anthem, JPMorgan Chase & Co analysts wrote in a note.

(Reporting by Diane Bartz in Washington; Additional reporting by Caroline Humer and Carl O'Donnell in New York; Editing by Andrew Hay and Lisa Shumaker)

By Diane Bartz