The chemist at the heart of the state drug lab scandal that has sent shock waves through the Massachusetts criminal justice system would alter drug samples, sprinkling real cocaine in with a non-drug substance in order to make the test turn out positive, a prosecutor said today in court.

Annie Dookhan also admitted she would grab a pile of 25 samples, test about five, and then list them all as positive, said Assistant Attorney General John Varner.

Varner spoke as Dookhan, whose mishandling of evidence over a multi-year period may ultimately undo thousands of drug convictions, was arraigned in Boston Municipal Court.

Advertisement - Continue Reading Below

Judge Mark Summerville set bail at $10,000, which her attorney said she expected to post today. Once free on bail, she must turn over her passport and wear a GPS monitoring device. She can have no contact with her former colleagues and must be in her house from 6 p.m. to 6 a.m. Another hearing was set for Dec. 3.

Dookhan’s family and defense attorney left the courthouse without commenting.

Dookhan was arrested by State Police at her Franklin home this morning. She faces two counts of obstruction of justice and one count of falsifying her academic records.

Attorney General Martha Coakley said at a news conference before the arraignment that Dookhan’s actions had “corrupted the integrity of the entire criminal justice system.’’

“This is the beginning,” Coakley said, noting that Dookhan faces more than 20 years in prison if given the maximum for the obstruction of justice charges and 2½ years for falsifying her academic record. “This is not the end of the charging. ... Her actions totally turned the system on its head.’’

Coakley said that Dookhan has cooperated with investigators, and the only motive that has so far emerged for her actions was Dookhan’s goal to be considered an effective worker at the Jamaica Plain drug lab.

“We have not identified a motive,’’ Coakley said, noting that in other cases of evidence mishandling suspects had drug problems or needed money.

Coakley said she did not currently anticipate criminal charges being filed against any of Dookhan’s co-workers at the now-closed Department of Public Health lab, but also said a sweeping investigation into the lab was underway.

Coakley said defendants were tried based on tainted evidence and the public as a whole has been victimized by Dookhan. “People absolutely deserve a system they can trust,’’ Coakley said, adding that repairing that trust “is going to take time and it’s going to be a complicated project.”

In Franklin this morning, a handcuffed Dookhan walked out of her home and into a police cruiser, as a large group of reporters looked on.

Annie Dookhan in a recent photograph (John Tlumacki/Globe Staff)

Dookhan wore glasses, her hair in a ponytail. She wore jeans and a gray sweatshirt. She did not say anything to the media. Before the cruiser drove away, her husband stepped out of the house, spoke briefly to a state trooper, and returned inside.

Dookhan is charged with lying about the integrity of drug evidence she analyzed in two instances and lying under oath about having a master’s degree in chemistry, the attorney general’s office said in a statement.

According to State Police reports obtained this week by the Globe, Dookhan has admitted to improperly removing drug evidence from storage, forging colleagues’ signatures, and not performing proper tests on drug evidence for “two or three years.”

State Police have warned defense attorneys and prosecutors in eastern Massachusetts that Dookhan tested 60,000 drug samples involving 34,000 criminal cases during her nine-year career in the now-closed Department of Public Health drug lab.

Authorities say 1,141 people are serving drug-related sentences in state prisons and county jails in cases where she was involved in testing the drugs.

Prosecutors say that she was charged under a state law that forbids misleading “a judge, juror, grand juror, prosecutor, police officer, federal agent, investigator, defense attorney, clerk, court officer, probation officer or parole officer.”

Dookhan also claimed on her resume — and during sworn testimony — that she had a master’s degree in chemistry from the University of Massachusetts Boston, a claim that school officials have said was false because they have no record of issuing her such a degree.

At least 20 drug defendants have been freed, had their bail reduced, or had their sentences suspended, because the evidence in their cases was analyzed by Dookhan. Many more are likely to be freed as the investigation continues by attorney David E. Meier, named by Governor Deval Patrick to determine the scope of the scandal’s impact.

Dookhan told State Police she recorded drug tests as positive when they were negative “a few times” and sometimes tested only a small sample of the drug batch that she was supposed to analyze, the Globe reported this week, based on the State Police report.

“I messed up. I messed up bad. It’s my fault,” she told troopers who visited her Franklin home on Aug. 28. She insisted that she acted alone, saying, “I don’t want the lab to get in trouble.”

The fact that a substance seized from an alleged criminal has been proven to be drugs by scientific testing is a keystone of any drug case. Law enforcement officials thus must be extremely scrupulous and painstaking about the handling of seized drugs. Otherwise, questions can arise about whether the material tested is the same material as that seized from the defendant and whether the tests performed on it were accurate.