A controversial bill virtually repealing the Hatch Act of 1939 by lifting most restrictions on participation in politics by 2.8 million federal employees passed the House yesterday, 244 to 164.

Whether that vote will be enough to overcome problems the bill faces in the Senate was not clear. Sen. Abraham A. Ribicoff (D-Conn.), chairman of the Senate Government Operations Committee, which has jurisdiction over the bill, has opposed it in the past and said he would not push for it this year unless it passed the House by a wide margin, even though President Carter supports the legislation and announced he will sign it.

Organized labor, the chief backer of the bill, recovered in yesterday's voting from some of the political damage it suffered when the bill was pulled from the floor three weeks ago, after an anti-labor amendment was adopted in a confused late night session.

The anti-labor amendment offered by Rep. John Ashbrook (R-Ohio), would prevent federal employee unions, such as the Postal Workers or the American Federation of Government Employees, from using duties or fees for any political purposes whatsoever, including even voter registration or informing members of an upcoming election.

On a key 266-to-139 vote yesterday, this Ashbrook amendment was largely nullified by an amendment saying that the bill could not make illegal any union political activity that is legal now.

Rep. Stephen Solarz (D-N.Y.) said the Ashbrook amendment was a "gag rule on legitimate labor activity" and a "legislative lemon."

Rep. Phillip M. Crane (R-Ill.) said the vote nullifying the Ashbrook amendment showed "labor has really done their work in the intervening weeks."

The temporary withdrawal of the Hatch Act repealer three weeks ago was the second rebuff this year for labor in the heavily Democratic House. The first setback came when the House defeated a bill to allow expanded picketing at construction sites, a bill labor had made it first legislative priority.

Opposing the Hatch Act repealer yesterday were Republicans, Common Cause, the Civil Service League and Americans United Against Union Control of Government, a "cousin" of the right-to-work lobby.

They contended that the federal employees, including the 347,000 who live in the Washington metropolitan area, wanted to keep the protection from political influence that the Hatch Act provides.

Passage of the bill would lead to politicization of the federal bureaucracy and a return to the spoils system the civil service merit system was designed to abolish, they said.

Rep. Edward Derwinski (R-Ill.) said the House was "turning loose a monster which could be used against any one of us" and that it was being "turned loose against its will."

Democrats, organized labor and the American Civil Liberties Union argued that preventing federal workers from actively participating in politics denied them a fundamental democratic right.

The merit system, which covers two-thirds of federal job holders, is sufficient protection from political abuse of the bureaucracy, they said.

In addition, they cited restrictions built into the bill, prohibiting officials from using their authority to coerce employees politically prohibiting political activity on the job and prohibiting solicitation of political contributions by superiors.

Under the Hatch Act, federal workers can vote, express their opinion, wear buttons, voluntarily contribute to political campaigns, and run for nonpartisan offices, but they cannot run for most state, local and federal offices or solicit funds for candidates.

The bill passed yesterday would allow them to run for political office, taking a leave of absence with a guarantee of their job or a similar one back if they lose. They could solicit funds or campaign, but not in federal buildings or on the job.

A few workers, such as employees with audit, inspection, prosecutorial and law enforcement authority would stay "Hatched," as would all workers involved in national security jobs.

President Theodore Roosevelt first issued the ban on political activity for civil service employees in 1907, but it covered only a quarter of government workers, since most weren't under civil service. A scandal during the New Deal days involving political coercion of temporary employees led to passage of the Hatch Act in 1939, which covered most federal employees.