He had been awaiting trial after a 23-page grand jury report last fall vilified him as a "manipulative and predatory" rapist and his accuser, 52, testified in detail about the alleged assault.
In their motion to drop the charges, prosecutors said "ample probable cause" remained to support Kerns' arrest.
But Ferman said she had referred the case to state prosecutors because it represents a conflict of interest for her office.
As he left the Norristown hearing where prosecutors dismissed the charges, Kerns thanked his family, friends, and lawyer, Brian McMonagle, for standing by him.
"I'm very happy, obviously," Kerns said in his first public comments since his arrest.
McMonagle, who hired the toxicologists who he said reviewed the lab results and identified the error, called it "an honest mistake" by the prosecutor's office.
Still, McMonagle said, "this has been a horrible ordeal for him and his family."
Kerns, of North Wales, was charged with drugging the employee of his Lansdale law firm, Kerns, Pearlstine, Onorato & Hladik, and raping her while she was unconscious after an Oct. 25 party at the Radice restaurant in Blue Bell.
The grand jury report said Kerns had offered the woman a ride after learning she felt too drunk to drive. Kerns took a bottle of wine and two glasses into his car, the grand jury report said, and gave the woman a drink. After she passed out in his car, he allegedly sexually assaulted her, once in his car and once at her home.
After first going to Grand View Hospital in Sellersville, the woman was examined at Abington Memorial Hospital two days after the alleged attack. Medical personnel found internal injuries, bruises, and other marks on her body, and collected blood and urine samples for testing by Quest Diagnostics, court records show.
Kerns faced 19 counts, including rape of an unconscious victim, sexual assault, tampering with evidence, and lying to authorities.
According to prosecutors' dismissal motion, a nurse at the Sellersville hospital had told the accuser the lab tests indicated traces of the sleep drug were found in her system. A detective later reviewed the results and read them the same way.
McMonagle said the experts he hired discovered the lab report had concluded there was no amount of the drug in her system.
Ferman said her staff conferred with McMonagle, reexamined the evidence, and conceded the mistake.
"Of course, you can imagine, I didn't understand how that had happened," she said.
The only just course, Ferman said, was to withdraw the charges. "The accused and the victim both have the right to justice," she said.
Ferman said she had referred the case to Attorney General Kathleen Kane because it now represented an conflict-of-interest for her office, which is conducting an internal review.
"The mistake that was made by members of my staff was significant enough that I felt that my interest in protecting the office and in them as well was impacting my ability to make a proper decision," Ferman said.
A spokesman for Kane confirmed that the District Attorney's Office had referred the case to the state and that the office "assumed the file."
Kerns led the Republican Party from 2008 until he resigned in November. His successor, State Rep. Mike Vereb, declined to comment Monday.
Inquirer staff writer Ben Finley contributed to this article.