A federal judge temporarily blocked the proposed takeover by Mobil Corp. of Marathon Oil Co. shortly before midnight Sunday as a thicket of legal measures and countermeasures began springing up around the controversial bid.

U.S. District Court Judge Frank Battisti of the Northern District of Ohio signed a temporary restraining order at 11:42 p.m. Sunday barring Mobil from continuing with its $85-a-share offer for up to 40 million shares of Marathon. The order had been sought by Marathon, which filed an antitrust suit opposing Mobil's purchase offer.

Mobil is the nation's second-largest oil company, and Marathon is ranked 16th.

After Marathon announced both the granting of the court order and the unanimous opposition of its board of directors to the proposed $5.1 billion takeover yesterday morning, Mobil moved immediately to try to get the court order reversed, and arguments on its request were scheduled for today.

Trading in Marathon's stock, which was halted Friday at $67.13 a share after Mobil's announcement, was suspended most of the day yesterday. It opened at 3:13 p.m., up 22 7/8 at 90, only to close 10 minutes later because of the heavy volume of orders. Even in that brief span of time, the stock managed to be the fourth most active issue traded on the New York Stock Exchange.

Although many analysts have predicted that a competing offer will emerge for Marathon, as of late yesterday none had.

In a related development, officials of the two agencies said yesterday the Federal Trade Commission, and not the Justice Department, will conduct the antitrust review of the takeover bid.

The two agencies had been at odds over which one would review the bidding war for Conoco Inc., a fight which was won by E.I. du Pont de Nemours & Co. That purchase was permitted only after the Justice Department forced an an end to a joint venture between Conoco and Monsanto Co. A Justice Department request to Mobil for data also delayed its unsuccessful takeover offer.

It was suggested that the assistant attorney aeneral for antitrust, William Baxter, wanted jurisdiction over the merger so that his agency could make a Reagan administration policy statement on mergers. At the time, Baxter's representatives fought FTC efforts to bring review of that merger to the independent commission.

But in July when that decision was made, the FTC consisted of two Democrats and two Republicans and was being run by an acting chairman, David Clanton. Last month, James C. Miller III, a former admininstration official, became chairman, and the commission now has three Republicans and one Democrat.

Miller has pledged a tough attitude on horizontal mergers, that is, those between competitors, telling a press conference last week that the commission would "scrutinize very carefully horizontal mergers" that would result in "significant aggregations of power" and that the commission aggressively sought authority to review this merger.

But Miller, an economist, has been sharply critical of federal antitrust policy, suggesting that the FTC has strayed too far into unconventional areas. The commission can review the merger until late this month, when it is likely to take formal action to delay it, seek additional information from the companies or drop the review.

Marathon's board recommended from its headquarters in Findlay, Ohio, that shareholders reject the Mobil offer, calling it "grossly inadequate" and "not in the best interests of the company or its shareholders." The board also said the offer raises major antitrust and other public policy issues that may mean it is doomed to fail. At the same time it announced the legal steps it is taking to bar the takeover.

The court order that Marathon secured barred Mobil from taking further action to implement its tender offer and will remain in effect until Saturday. The court order also restrains Mobil's agent in the takeover, Merrill Lynch, Pierce, Fenner & Smith Inc.

Mobil's offer to pay $85 a share for up to 40 million shares--or about two-thirds--of Marathon common stock is dependent upon Mobil obtaining at least 30 million shares by Nov. 11. Mobil has said that it intends to acquire shares beyond the 40 million in a securities trade, which would take the cost of the entire package to $5.1 billion.

"We weren't surprised by the court order. We don't agree with it, and we're taking legal steps to get it reversed," said John Flint, a spokesman for Mobil. Mobil yesterday asked Judge Battisti to review the restraining order and to consider dissolving it.

"We are very pleased that the court has issued the temporary restraining order," said Harold D. Hoopman, president and chief executive officer of Marathon. 'We believe that Mobil's proposed takeover of Marathon would clearly violate the antitrust laws."

In its complaint, Marathon used several figures to illustrate what it said would be the antitrust impact of the proposed purchase. For instance, according to papers filed by Marathon, in 1980, Mobil ranked fourth in sales of U.S. motor gasoline and Marathon ranked 12th. Together they would be ranked first, the complaint said. In total liquid pipeline mileage in the United States, Mobil and Marathon ranked second and 15th, but would rank first together, the complaint said.