A federal judge on Wednesday approved Paramount’s antitrust settlement with 12 states that had sued to stop its takeover of Warner Bros. Discovery, removing the last legal obstacle to the $81 billion merger and putting the deal on track to close Oct. 6.

Minutes after the ruling, Paramount’s chief executive, David Ellison, announced that Ynon Kreiz, who has run the toy maker Mattel for eight years, would join Oct. 5 as co-chief executive of the combined company and take a seat on its board. Mr. Ellison will remain chairman and chief executive. “It’s a division of labor built on our complementary strengths, with clear reporting lines,” he said in a statement, adding that Mr. Kreiz would handle day-to-day management and the integration of the two businesses while he kept strategy and creative direction.

The merger joins two of Hollywood’s last five legacy studios and puts HBO Max and Paramount+, MTV and the Discovery networks, and CBS News and CNN under one roof, creating one of the largest media companies in the world. A name for the new company could come as soon as Thursday.

U.S. District Judge Araceli Martinez-Olguin called the consent decree a “fair, reasonable, and good faith approach to address the competitive harms” the states had alleged, and said it was reached fairly and was “procedurally sound.” She had not moved quickly: at a hearing on Thursday she told the parties the court was not a “rubber stamp,” gave outside critics, including the Block the Merger coalition and the League of United Latin American Citizens, a window to file objections, and ordered Paramount and the states to answer a letter from Senator Cory Booker, Democrat of New Jersey, seeking a fuller review.

On Wednesday she turned those requests aside. Critics had raised “meaningful grounds for disappointment,” she wrote, including whether CNN and CBS News could stay independent and whether less competition would mean fewer ambitious films. “But these hopes and desires for the proposed consent decree to reach farther — to achieve more — do not rise to the level of legal violations upon which the Court can reject the parties’ negotiated resolution,” the judge wrote, calling the settlement a compromise that “saves the risk, time, and expense of litigating through trial.”

The five-year agreement requires Paramount to release at least 30 films a year for its first two years and 32 a year for the three after, with a $30 million fine for each film not produced and a possible forced sale of the Miramax studio if the quota is missed. At least 20 percent of the films must be made in the United States at first, rising to 30 percent, with separate quotas for big-budget “tentpole” pictures and independent films. Paramount and Warner must also negotiate cable packages for their channels separately, an independent monitor will oversee compliance, and Paramount committed millions of dollars to a fund for workers displaced by the merger.

A five-member editorial independence board will monitor CNN and CBS News. California’s attorney general, Rob Bonta, who led the states’ case, said it was meant to “ensure independent, objective, fact-based reporting at CBS News and at CNN.” The members, all journalists, will be appointed by the merged company’s board and will report to its chief compliance officer, which critics say leaves Paramount choosing its own watchdog.

The states settled the lawsuit last week, after suing in July with the initial goal of blocking the deal outright. They argued a combined company would “extinguish competition” and leave moviegoers and cable customers with fewer choices. Judge Martinez-Olguin first ruled in the states’ favor and barred Paramount from taking control of Warner Bros. for weeks that stretched into months. Settlement talks began in mid-September, and an agreement was announced Sept. 21, after Mr. Bonta had walked away from an earlier round, accusing Paramount of leaking details to reporters. The company denied that. Announcing the settlement, Mr. Bonta said it was about “protecting people’s careers, the lives they’ve built here in California,” while insisting it was not an endorsement of the merger.

Other obstacles had already fallen. The federal government approved the merger in June, and the Trump administration cleared at least 49.5 percent of the financing to come from government-backed sovereign wealth funds in Saudi Arabia, Qatar and Abu Dhabi. Paramount says the funds will hold no voting power, which will rest with Mr. Ellison, his billionaire father, Larry Ellison, and RedBird Capital Partners. The Writers Guild of America, which filed its own suit in July, settled with Paramount last week, saying it could not continue the fight alone.

Paramount has long rejected the critics’ case, saying the deal means “creators have more avenues for their work, not fewer,” and Mr. Ellison has said he “do[es] not aspire to lead” CNN and CBS “to bend their newsrooms to my views.” “I think the most important thing that turned the tide was the realization that there wasn’t an antitrust case,” Makan Delrahim, Paramount’s chief legal officer, said Wednesday at a conference hosted by TheWrap.

The court’s timing was tight. Beginning Thursday, Paramount owes Warner Bros. shareholders $7 million for each day the deal remains open under a “ticking fee” that had pushed the company hard toward settling; it had warned the court that delaying a trial could cost it $1.9 billion and had threatened to pull its operations out of California.

Opponents said the fight was not over. The settlement is “toothless,” the Block the Merger coalition said in a statement, and “allowing the Paramount Skydance-Warner Bros. Discovery merger to move forward with no meaningful structural remedies will cost jobs, mute creativity, weaken independent journalism, and damage our First Amendment rights.” But if there was one benefit to the approval, the group said, it was that “people are now wide awake and paying attention,” and their anger “is not going to fade away.”