The House Judiciary Committee, beating the National Rifle Association to the punch, unanimously approved a compromise gun-control bill yesterday that stakes out a middle ground between sportsmen and police groups.

The committee's 35-to-0 vote climaxed a race with the NRA, which is trying to bypass the panel and force a House vote on a competing measure that would weaken the 1968 Gun Control Act. The NRA and other supporters had gathered 209 signatures on a discharge petition, nine short of the majority needed to force their version to the floor.

The compromise, achieved by Rep. William J. Hughes (D-N.J.) in the panel's crime subcommittee, would require that police be notified about all handgun sales so they can check the background of the purchaser. However, it drops an earlier Hughes proposal to impose a 15-day waiting period before handgun sales could be made.

Hughes said a unanimous vote on such an emotional issue is "very significant" and that he expects some of those who signed the discharge petition to back the compromise. Committee Chairman Peter W. Rodino Jr. (D-N.J.) said the House will take up the measure next week. It appears certain to be considered ahead of the NRA-backed version, which is supported by the Reagan administration and passed the Senate, 79 to 15, last summer.

NRA official Wayne R. LaPierre Jr. vowed to continue to press the fight on the House floor, saying, "There are tremendous problems in this bill for the law-abiding citizen."

LaPierre particularly objected to the police background check, saying this "will bring the federal government into millions of dollars of needless paper work. Studies show that criminals buy their guns on the black market or steal them. They don't go into a gun shop and fill out forms."

But a coalition of police groups welcomed the compromise bill, with spokesman Dan Rosenblatt calling it "a signal that the law-enforcement community has been heard in the House of Representatives."

Barbara Lautman of Handgun Control Inc. said "the background check is a start" but that her group would continue to seek a waiting period for handgun sales. Still, Lautman called the bill "a great improvement" that could "stop the NRA from gutting the 1968 act."

The Hughes bill would allow interstate sales of rifles if the sales were made in person and complied with the laws of both states. Unlike the Senate bill, it would not ease restrictions on interstate handgun sales.

The Hughes bill resembles the Senate version in allowing people to cross state lines with an unloaded, inaccessible rifle; easing record-keeping rules for dealers; allowing dealers to make sales at gun shows, and requiring proof of intentional violations for felony convictions.

But it also includes a mandatory 10-year prison term for using a machine gun in a violent crime or drug-trafficking offense; makes it a crime to knowingly sell a gun to a criminal, drug addict, mental incompetent or illegal alien; bars sale of silencers, and expands an import ban on parts for cheap handguns.

The NRA-backed bill would bar federal agents from conducting surprise inspections of gun dealers, and from using the evidence gathered unless it involved willful record-keeping violations or illegal sales.

It would also narrow use of mandatory penalties for violent crimes committed with a gun.