President Carter legally used his appointment powers during last year's congressional recess to name a controversial nominee, John McGarry, to the Federal Election Commission, a federal judge ruled here yesterday.

U.S. District Court Judge Harold H. Greene said that the Senate, which twice failed to act on McGarry's nomination, could have rejected the appointment and then Carter would have been unable to name McGarry to the election regulatory panel.

But Greene said that "since the Senate failed to do so, there is no implication that a recess appointment is improvident."

Neil Staebler, who was appointed to the election commission by then-President Gerald R. Ford, has continued to serve on the panel, even though his term expried on April 30, 1977. Carter appointed McGarry to fill Staebler's post on Sept. 27, 1977, but the Senate adjourned without confirming McGarry in 1977 and again last year.

McGarry's nomination ran into trouble when some Republican senators voiced misgivings about McGarry's background as a special counsel to the House Administration Committee and explanations of his tax returns and House financial disclosure statements.

The Senate Rules Committee approved McGarry's nomination last August and it was debated on the Senate floor. But the nomination again lapsed when Congress adjourned in mid-October.

Carter then appointed McGarry to an FEC term which expires April 30, 1983, but Staebler filed suit seeking to block McGarry's taking the FEC seat-Staebler claimed that FEC rules say that a commissioner can only take office "upon nomination by the president and confirmation by the president and confirmation by the Senate."

But Greene said that the "plain implication" of the law establishing the FEC is that vacancies occur when terms of office expire.

"The court finds it difficult to believe that, had the Congress intended to take the significant step of attempting to curtail the president's constitutional recess appointement power, or even to legislate in the area of that power, it would not have considered the matter with more deliberation or failed to decide its purpose with greater directness and precision," Greene said. "No such deliberation or direction can be found in the legislative history."

Greene said that Stebler has already served for more than 30 months, even though he was nominated and confirmed for an 11-month term. The judge said that if he were to preclude Carter from making a recess appointment, Staebler would likely serve well into 1979 and perhaps longer.