Pro-gun rights Democrats teamed with House Republicans on Thursday to block local governments and law enforcement agencies from gaining routine access to gun-purchasing data.

The House Appropriations Committee defeated two attempts by gun control advocates to strip four-year-old restrictions on the use of information from Bureau of Alcohol, Tobacco, Firearms and Explosives tracing gun sales. The votes were a victory for the National Rifle Association and came despite the Democratic takeover of Congress in January.

The committee's emotional debate often focused on broader gun rights issues rather than the matter at hand, involving when the bureau can share such information.

Gun control advocates say the gun sales data is essential to uncovering dealers who sell guns that disproportionately end up in the hands of criminals.

Gun rights advocates, led by Rep. Todd Tiahrt, R-Kan., said mayors such as New York City's Michael Bloomberg want the data to sue out-of-state gun dealers.

Tiahrt, the key sponsor of the restrictions on sharing gun trace data, also said easing the restrictions could lead to the disclosure of police officers' identities and other details to criminals.

"What the Tiahrt amendment does is protect those who protect us," Tiahrt said.

Pro-gun advocates say the data-sharing restrictions protect gun owners' privacy. But Bloomberg and other mayors contend they hamper law enforcement authorities' ability to trace illegal guns and arrest weapons traffickers.

"This handcuffs the cops, not the criminals," said Rep. C.A. "Dutch" Ruppersberger, D-Md.

More than a dozen Democrats, most from rural districts, joined with all but two committee Republicans to defeat a bid by Rep. Patrick Kennedy, D-R.I., to ease the data sharing restrictions but ensure that police officers' names would not be compromised.

Earlier, a bid by Rep. Jim Moran, D-Va., to reject Tiahrt's language altogether lost by a voice vote.

The mayors say gun tracing data helps police departments determine the source of illegal guns, who buys them and how they are distributed.

Almost three-fifths of guns used in crimes are sold by just 1 percent of gun dealers, who forge relationship with gun traffickers making multiple purchases.

Under Bloomberg, who recently left the GOP amid speculation he may run for president as an independent, the city has sued out-of-state gun dealers in an attempt to reduce the flow of illegal guns into New York. The NRA-backed restrictions block cities from getting ATF data for such suits.

The committee chairman, Rep. David Obey — a liberal Democrat representing a rural Wisconsin district — said the issue was only marginally related to gun rights. He opposed the efforts to ease the data restrictions.

But Obey lashed out at both the NRA, which failed to endorse him in his most recent race despite his pro-gun rights record, and Bloomberg. He said the mayor's representatives came to his office and threatened to run television ads attacking him.

The votes came as the committee approved a $53.6 billion bill for the departments of Commerce and Justice, as well as NASA and science programs.