CLARKSBURG, W.Va. — In her three years as a nursing assistant on the overnight shift at the local Veterans Affairs hospital here, Reta Mays tended to elderly veterans with the ailments of old age. She took their vital signs and glucose levels on the graveyard shift, sitting vigil at their bedside while medical staffing was thin. Few saw her go in and out of patients' rooms.

No one watched while she injected them with lethal doses of insulin during an 11-month killing rampage in 2017 and 2018, which she admitted to Tuesday in federal court, pleading guilty to second-degree murder in the deaths of seven veterans and an intent to murder an eighth who died two weeks later.

Prosecutors said they still have not determined why she did it. But after a two-year investigation into a pattern of suspicious deaths that took the hospital almost a year to detect, Mays, who had denied any wrongdoing in multiple interviews with investigators, told a federal judge she preyed on some of the country’s most vulnerable service members.

The deaths gripped this Appalachian community four hours west of Washington and were an embarrassment for leaders of the sprawling and long-troubled VA system, which President Trump promised to reform. The investigation by William Powell, the U.S. attorney for the Northern District of West Virginia, and VA Inspector General Michael Missal’s office took two years. Its reverberations reached the highest levels of the Justice Department.

Mays, a 46-year-old Army veteran hired by the Louis A. Johnson Medical Center in 2015 with no certification or license to care for patients, chose victims admitted to the hospital from July 2017 through June 2018 with heart conditions, strokes, cancer. A few had mild diabetes. But they were not about to die, court documents show.

In the middle of the night, with a small staff on the medical surgical ward known as 3A, Mays injected the patients with insulin she was not authorized to administer, leading to their deaths from severe hypoglycemia or low blood sugar, investigators said.

About 26 family members of the victims attended the hearing in person, all wearing masks, while others watched via Zoom video conference. By pleading guilty to all of the charges, Mays waived the right to have the case presented to a grand jury.

With her voice breaking under a white mask, Mays sobbed near the end of the proceeding,

“Did you, in fact, do what the government says you did?” U.S. District Judge Thomas Kleeh asked.

“Yes, sir,” she replied. A mother of three sons, she served in the Army National Guard from November 2000 to April 2001 and again from February 2003 to May 2004, when she deployed to Iraq and Kuwait. She told the judge she was taking medication for post-traumatic stress disorder.

Wearing a cream-colored blouse and black skirt, with short brown hair, Mays was handcuffed by U.S. marshals and remanded to the Northern Regional Jail in Marshall County. A sentencing hearing has not been scheduled.

It remains unclear why Mays gave fatal doses of insulin to the veterans she was charged with watching. Powell said he expects Mays and her attorneys may reveal more at her sentencing in the coming months. Prosecutors plan to ask for consecutive sentences of life in prison.

Powell read the names of each victim and their military service. Two of them fought in World War II. He said each family was asked and consented to her plea deal in lieu of an indictment and trial.

After the hearing, Steven Edgell, of Barbour County, W.Va., told reporters he was satisfied with Mays’s plea but also longed to know her motive for killing his father, a U.S. Army veteran who served in Germany during the Korean War and played in the Army band. Archie Edgell was 84 when he died.

“I’d like to know why she kept on doing it. Was she planning on being God or something?” Steven Edgell said.

The hospital has come under fire for leaving its insulin supplies so easily accessible and for failing to more quickly detect the suspicious pattern of the deaths, issues Missal said would be addressed in an upcoming report.

Investigators had focused on Mays from the start, moving to have her taken off patient care once the hospital notified the inspector general’s office in July 2018. But they had to build a circumstantial case because the hospital ward does not have cameras in patients’ rooms, and cameras in the common areas, including the supply room where insulin was kept, were not working, investigators said.

Similarities were identified in the deaths: Elderly patients in private rooms were injected in their abdomen and limbs with insulin the hospital had not ordered — some with multiple shots, according to people familiar with the case. Within hours, the veterans’ blood-sugar levels plummeted.

Several bodies were exhumed, and at least three deaths were ruled homicide. The armed forces deputy medical examiner changed the death certificates of the others from “natural causes” to “undetermined,” according to autopsy reports and people familiar with the case.

As the investigation lingered, Attorney General William P. Barr at least twice called Powell to ask about the status.

Powell also faced pressure from Veterans Affairs Secretary Robert Wilkie and West Virginia Sens. Joe Manchin III (D) and Shelley Moore Capito (R). Manchin criticized hospital leaders in Clarksburg for taking too long to put the pieces together in the deaths.

“While overdue, today justice is finally being served," Manchin said in a statement Tuesday. “I will not stop until we determine how this could have happened, and ensure it never happens again. . . . My heart goes out to the families and loved ones who tragically lost a Veteran and have had to endure this injustice.”

Other criminal cases have engulfed the agency in the past year, intensifying questions about whether the country’s largest health-care system is doing enough to protect veterans in its care. A former osteopath at the VA hospital in Beckley, W.Va., was charged with multiple counts of sexual assault. A former VA pathologist in Fayetteville, Ark., pleaded guilty in June to manslaughter after officials say he misdiagnosed thousands of patients while using drugs or alcohol.

The families blamed hospital leaders for not detecting a pattern in the deaths sooner.

Melanie Proctor, whose father’s body was one of seven disinterred last year and taken to Dover Air Force Base in Delaware for a forensic autopsy, told The Washington Post last fall that she was angry VA “still has not stepped forward to say what they have fixed to make sure this doesn’t happen again.”

Felix McDermott’s blood sugar had plunged to dangerous levels hours before the retired Army sergeant died in April 2018 of hypoglycemia.

Mays was fired from the hospital last year, seven months after being removed from patient care, after it was discovered she had lied about her qualifications on her resume.

The Clarksburg hospital, in a statement, repeated what it has said throughout the investigation — that it discovered the misconduct and reported it to the inspector general. “Our hearts go out to those affected by these tragic deaths.”