A former hospital technician in Maryland, New Hampshire and other states who caused patients as old as 80 to become infected with hepatitis pleaded guilty to leaving dirty syringes for hospitals to use after injecting himself with stolen painkillers.

The technician, David Kwiatkowski, had admitted previously to knowing he was infected with hepatitis C. In papers filed on Monday in a New Hampshire federal court, he pleaded guilty to 14 criminal counts related to seven cases in which he caused infections in patients ranging in age from about 40 to more than 80.

The plea deal would allow Kwiatkowski to avoid federal charges in Maryland, Kansas and Georgia. He worked at 18 hospitals in seven states, including the Baltimore VA Medical Center, Johns Hopkins Hospital, Maryland General Hospital and Southern Maryland Hospital in Maryland. Seven related hepatitis cases were found in Maryland.

Rod J. Rosenstein, the U.S. attorney for Maryland, signed off on the plea deal. He said that while Kwiatkowski will not be tried in Maryland on federal charges, his actions here and in several other states will be taken into account when he is sentenced. Kwiatkowski could also still face charges in Maryland state court, but Rosenstein said state's attorneys typically don't pursue them if a defendant is already committed to a lengthy federal prison sentence.

"I think it's appropriate because it's an egregious abuse of trust," Rosenstein said of the plea deal and sentence. "Given the defendant's current age, that means he'll be spending most of his remaining life in federal prison."

Maryland victims will get the chance to weigh in at Kwiatkowski's sentencing. All victims are given the chance to be heard in person or in writing, Rosenstein said. Rosenstein did not know if any Marylanders planned to speak.

Kwiatkowski told police after his arrest in July 2012 that he realized his actions could "kill a lot of people," according to court papers.

He was working at Exeter Hospital in New Hampshire in early 2012 when he began stealing syringes of the powerful pain medication Fentanyl, according to court documents. Hospital workers unwittingly used the refilled dirty needles on patients.

Kwiatkowski estimated to police that he swapped out syringes on about 50 occasions while working at Exeter Hospital. He said he had also swapped out syringes at least 20 times when he worked in Kansas and 30 times in Georgia, according to court documents.

He pleaded guilty to seven counts of tampering with a consumer product and seven counts of obtaining controlled substances by fraud. The charges carry a prison sentence of 30 to 40 years.

After he began working at Exeter Hospital in 2011, hospital officials identified several unexplained cases of hepatitis C. An investigation showed the outbreak came from drugs diverted by Kwiatkowski, who denied knowing that he had the disease.

Police searched his car and found an empty syringe with a blue "Fentanyl" label similar to those used at Exeter Hospital, along with several needles, one containing Kwiatkowski's DNA.

After his arrest, he admitted to being diagnosed with hepatitis C in 2010 while working in Kansas and "swapping out" syringes of Fentanyl with those of saline solution at Exeter Hospital.

"It was all me," he told investigators. "And I'm going to kill a lot of people out of this. … I'm killing a lot of people."

Before moving to New Hampshire, Kwiatkowski worked at health care facilities in Kansas, Michigan, Maryland, Georgia, Pennsylvania, Arizona, Kansas and New York. He was fired twice and once resigned amid an investigation into missing controlled substances, according to court papers.

As a result, authorities conducted a massive investigation, recommending that more than 11,000 people get tested for possible hepatitis C infection.

The disease can cause liver damage, as well as other health issues, and can be fatal.

Baltimore Sun reporter Scott Dance contributed to this article.