A federal judge said Tuesday that AT&T's $85.4 billion purchase of Time Warner is legal, clearing the path for a deal that gives the pay-TV provider ownership of cable channels such as HBO and CNN as well as film studio Warner Bros.

U.S. District Court Judge Richard Leon did not impose conditions on the merger's approval. He also urged the government not to seek a stay when issuing his decision in a closed-door room with reporters.

AT&T General Counsel David McAtee said the company was happy with the result.

"We are pleased that, after conducting a full and fair trial on the merits, the Court has categorically rejected the government's lawsuit to block our merger with Time Warner," McAtee said in a statement. "We look forward to closing the merger on or before June 20 so we can begin to give consumers video entertainment that is more affordable, mobile, and innovative."

Shares of Time Warner jumped roughly 5 percent in extended trading. Shares of AT&T dropped as much as 2 percent.

Assistant Attorney General Makan Delrahim said the Justice Department was disappointed with the decision.

"We continue to believe that the pay-TV market will be less competitive and less innovative as a result of the proposed merger between AT&T and Time Warner. We will closely review the Court's opinion and consider next steps in light of our commitment to preserving competition for the benefit of American consumers," Delrahim said in a statement.

The outcome of the trial could spur a wave of deals in the telecom and media industries, as well as clear the way for future vertical mergers, where a company buys its supplier. Comcast has been eyeing a similar merger to combine production and distribution in a competing bid for Twenty-First Century Fox and was preparing to announce an offer as soon as Wednesday if Leon ruled in favor of AT&T in the trial, people familiar with the matter told CNBC.

Comcast shares dipped 4 percent after the AT&T-Time Warner decision. Shares of Fox rose 4 percent.

The decision comes after a six-week trial. The DOJ sued last year to block the merger, citing concerns that AT&T, owner of satellite television provider DirecTV, could charge rival distributors more for Time Warner content, resulting in higher prices for consumers.

AT&T countered that the logic doesn't hold up since the point of owning content is to get widespread distribution, which brings in affiliate fees and advertising revenue.

AT&T, also the No. 2 wireless carrier in the U.S., announced in October 2016 that it was buying Time Warner to diversify its revenues and also become a media powerhouse that could attract consumers by bundling entertainment with mobile service. CEO has said the deal would help AT&T compete against tech giants like Amazon and Netflix, which are investing more in content.

There will be no divestment of any assets in the completion of the merger, Daniel Petrocelli, lead trial attorney for AT&T, told reporters after the decision.

In a nearly 200-page decision, Leon said that he ultimately concluded that the government failed to meet its burden to establish that the deal was likely to lessen competition substantially.

Read Leon's full decision below: