WASHINGTON—A federal judge ruled Tuesday that AT&T Inc. can proceed with its blockbuster acquisition of Time Warner Inc., without any conditions, marking a historic defeat for the Justice Department that could rewrite the media landscape and set the stage for other deals.

U.S. District Judge Richard Leon told a packed courtroom that the department hadn’t proved its case that the deal would suppress competition in the pay-TV industry.

At one point waving his 172-page opinion in the air, Judge Leon declared: “The court has now spoken and the defendants have won.”

The moment provided a final act of drama in a case that carried the highest stakes for the two companies, their leaders and the Trump administration’s antitrust enforcement. President Donald Trump was unusually direct in opposing the deal, both before and after taking office, giving the case an unusual political cast.

The decision, in one of the biggest antitrust cases in decades, is a milestone victory for AT&T as it looks to reposition itself in a rapidly evolving media landscape. Its deal for Time Warner, now valued at roughly $80 billion, has been pending since October 2016.