A federal judge here ruled yesterday that President Carter over-stepped his authority in imposing an oil import fee that would have increased the price of gasoline 10 cents a gallon starting tomorrow.

Carter imposed the fee in part to discourage energy consumption by driving up its costs, in part to raise extra money to help balance next year's budget.

To spread out and minimize its impact, he set up a system to pass along all of its added cost in gasoline prices nationwide, rather than let it fall on heating oil or disproportionately on such import-dependent regions as New England. That was his undoing.

U.S. District Court Judge Aubrey E. Robinson Jr. noted yesterday that, while Carter does have power to impose fees on imported oil, Congress has expressly denied him power to restrain gasoline consumption by imposition of any tax or fee.

Carter's fee plan, Robinson wrote, "is an attempt to circumvent that stumbling block in the guise of an import control measure."

White House press secretary Jody Powell quickly announced that the administration will appeal Robinson's decision to the waiting U.S. Circuit Court of Appeals for the District. That court three times in recent months has overruled district judges and upheld the president's power to take disputed actions in other fields.

Powell said the administration will seek "an expedited ruling," that it "continues to feel strongly that the . . . fee is sound and necessary," and that "we are . . . confident of our ultimate legal position."

If the import fee survives in the appeals court, however, it may be shot down in Congress. There have been moves in both House and Senate this week to scuttle the fee, even though both houses are also looking toward the $10.3 billion in revenue it would provide as insurance in balancing the fiscal 1981 budget they are now working on.

The administration was given one more chance yesterday to head off congressional action on repealing the import fee when a House Ways and Means subcommittee agreed to a one-day delay before voting on the measure.

The panel agreed to a postponement after Treasury Secretary G. William Miller asked permission to appear before the subcommittee this morning. Miller had passed up an earlier opportunity to testify.

However, subcommittee Chairman Charles A. Vanik (D-Ohio) said he was sure a majority would vote to roll back the import fee despite the secretary's testimony.

"The oil import fee is dead," Vanik told reporters.

Committee sources said an informal nose-count showed 17 of the subcommittee's 20 members in favor of repealing the fee. Under the new crude-oil tax bill, Congress may override by resolution any fee Carter imposes.

He can then veto the resolution of disapproval. Congress can override a veto with two-thirds votes in both houses. Carter thus needs only one-third plus one in either house to prevail on the issue.

House Speaker Thomas P. O'Neil Jr. (D-Mass.) said yesterday he thinks a resolution opposing the fee would pass on the House floor "in a walk."

A team of administration lobbyists, led by Miller, spent most of yesterday morning and afternoon visiting members of Vanik's subcommittee in an effort to persuade them to support the president's program.

The unpopularity of the import fee in the Senate was demonstrated Tuesday when that chamber voted against it on a procedural test vote, 75 to 19.

Sen. Bob Dole (R-Kan.), ranking minority member on the Senate Finance Committee and chief sponsor of the Senate's proposal to roll back the import fee, said yesterday he expected Robinson's decision would give Congress "more time to mobilize forces to kill this ill-advised measure for good."

"The administration was clearly having a hard time convincing either the Congress or the American people that this tax was either a conservation or a anti-inflation measure, as they claimed," Dole said in a statement.

Ironically, repeal of the oil-import fee could well inhibit congressional moves to cut taxes this year. Some lawmakers were counting on the fee to finance tax reduction.

The challenge to the president's oil import fee was brought to the federal court by a coalition of petroleum consumers, marketers, refiners, importers and five members of Congress.

Carter imposed the $4.62-per-barrel oil import fee March 15 as part of his new anti-inflation program, primarily to help ensure that the budget would be balanced.

He forbade oil companies from passing it along in higher gasoline prices until May 15.The White House estimates impositions of the oil-import fee would boost retail gasoline prices by 10 cents a gallon.

However, the import fee has been opposed in Congress by a coalition of New England and other consuming state members who fear it will lead to higher home heating-oil and other energy prices, and lawmakers from oil-producing states, who resent higher taxes on the oil industry.

The government had argued that Carter's plan, called the Petroleum Import Adjustment Program, was authorized under the Trade Expansion Act of 1962, which allows the president to take action to adjust imports when it has been shown that such imports "threaten to impair the national security."

In 1976, the U.S. Supreme Court upheld petroleum import fees imposed by the Nixon and Ford administrations under the Trade Expansion Act.

Judge Robinson noted yesterday, however, that in that case, the import fee directly affected the price of imported oil relative to domestic oil. Standing alone, Robinson said, Carter's fee would have the same effect. But, the judge concluded, Carter's overall program -- which provides that refiners reimburse importers for the fee and then pass on the cost to consumers generally -- neutralizes the effect of the import fee.

This is because the 10-cent-per-gallon conservation fee would ultimately be imposed on sales of all gasoline made from both domestic and imported crude.

That analysis, Robinson said, reduces the case to whether the president has the authority to impose a 10-cent "conservation fee" on all gasoline "to lower demand for the product." The answer, Robinson said, is that the Trade Expansion Act gives the president no such authority to impose controls on domestically produced goods.

Robinson said that possible effects of Carter's program on the level of oil imports "are far too remote and indirect" to be supported by the Trade Expansion Act alone.

For one thing, the judge said, the actual effect on import levels will be slight. Second, that slim impact entails extensive controls on domestic goods. Finally, he said, Congress has denied the president authority to use a gasoline conservation tax or fee to reduce comsumption.

The Trade Expansion Act, Robinson said, does not sanction "this attempt to exercise authority that has been deliberatley withheld from the president by Congress."

Robinson also rejected the government's contention that Carter has inherent authority -- independent of Congress -- to impose the gasoline conservation fee for national security reasons.

In his opinion, Robinson wrote that he would not question Carter's determination that the nation's dependence on foreign oil could have "severe consequences" on national security and threaten the nation's economic well-being.

But, Robinson said, "laudable purposes notwithstanding," he was compelled to determine whether Carter's action fell within the statutory authority granted him by Congress.

"Existing statutes cannot be used for purposes never contemplated by Congress and in way contrary to congressional intent," Robinson said in his 12-page decision.

If there were any doubts about that limit on the president's authority, the judge wrote, they were set aside by the Supreme Court in 1952 in the landmark case known as Youngstown Sheet & Tube Co. versus Sawyer. In that case, the high court heard similar arguments on behalf of then-president Harry S. Truman to justify seizure of steel plants -- by executive order -- in the face of an impending strike that posed both economic and national security threats.

When the Supreme Court struck down that order, Robinson said yesterday, it noted that "the president's order does not direct that a congressional policy be executed in a manner prescribed by Congress -- it directs that a presidential policy be executed in a manner prescribed by the president."