Rep. Robert L. Ehrlich Jr. ripped his gubernatorial rival yesterday for Maryland's failure to check the criminal backgrounds of hundreds of people applying to buy guns, taking the offensive on an issue that has dogged his campaign for weeks.

Ehrlich's campaign also unveiled a sharply negative television ad that criticizes Lt. Gov. Kathleen Kennedy Townsend (D) and her broader record on crime and gun control. Staff members said the ad would begin airing today in Baltimore and in the Washington region tomorrow.

In an interview, Ehrlich (R) said the state's refusal to help the FBI perform background checks on an estimated 500 people with criminal records this year was "just ridiculous. It's just negligence, very simple negligence that can add up in a very costly way."

Townsend said that the problem had been resolved this summer and that Ehrlich should focus instead on measures to improve gun safety, such as expanding a ballistic fingerprinting program.

"I think he's just criticizing gun enforcement because he doesn't want to have gun laws that work," she said.

Ehrlich's decision to go on the attack was an attempt to shift the debate on gun control, a volatile topic that until now has hamstrung his standing among many liberal and moderate suburban voters whose support he needs to win.

For weeks, Townsend has run television commercial ads of her own that slam Ehrlich for his legislative votes to effectively legalize the sale of certain so-called assault weapons and cheap handguns known as Saturday night specials. He has also taken heat for comments he made last month when he said he would review Maryland's strict gun control laws and possibly get rid of ones found to be ineffective.

But Ehrlich said it was irresponsible for Townsend to preach about gun control when her administration has failed to prevent criminals from buying firearms because of flubbed background checks.

Last week, state and federal authorities confirmed that state archivists notified the FBI in March that it would no longer perform the required background checks because budget cuts had left them shorthanded.

The problem persisted until July, when Maryland and federal officials agreed to provide $45,000 to the state archives to conduct the checks, which mostly involved examining old paper records for information not available in electronic databases. Officials could not say how many cases were affected, but the archives typically received about 500 requests in a four-month period.

"It's a singular but egregious example of gross inconsistency," Ehrlich said. "They're running around screaming about me, but they can't find $45,000 for the instant checks."

The subject of gun control has been hotly debated throughout the campaign, but the candidates have handled it more gingerly since a sniper began shooting people in the Washington region three weeks ago.

After the sniper first struck, Townsend said she would stop running ads that mention guns to avoid politicizing a sensitive issue. But after internal polls showed that few voters knew of Ehrlich's opposition to gun control, Townsend began running an ad.

Ehrlich aides said they had contemplated a more strident televised attack on Townsend's record on crime prevention and guns but decided against it because they did not want to alienate voters shaken by the sniper slayings.

Richard Vatz, a Towson University professor of mass communications, said that gun control was a risky subject for both candidates but that Townsend's record in office was fair game for Ehrlich.

"It's unethical for people to exploit this issue and to take advantage of the people in the Washington suburbs who are affected by the sniper," he said. "But in terms of effectiveness, [Ehrlich] must counter this. I think he'd be foolish not to respond."

Analysts said Townsend remains politically vulnerable for other well-publicized breaches of gun control laws during her tenure.

In 1999, Maryland State Police had to retrieve 49 handguns from people who were ineligible to buy them after examiners failed to conduct background checks in time. That same year, a Laurel man fatally shot his two children with a handgun that he was allowed to purchase even though he was subject to a domestic violence restraining order.

Gun control advocates, who have campaigned for Townsend, winced after last week's disclosure about the background checks. But they were careful not to blame Townsend, who oversees crime-prevention programs.

"I think if Kathleen Townsend had been informed, it would have been fixed right away," said Matthew Fenton of Marylanders Against Handgun Abuse Inc.

State Sen. Ida G. Ruben (D-Silver Spring) called the failure to conduct the background checks "outrageous" but likewise declined to criticize Townsend.

"There are errors that will be made in any administration," Ruben said. "But I believe if Mr. Ehrlich becomes governor, he'll set us back 10 to 20 years on gun control legislation."

Staff writers Amy Argetsinger and Matthew Mosk contributed to this report.