Democrat Kevin Steele won election Tuesday as Montgomery County district attorney, halting Republican Bruce L. Castor Jr.'s bid to reclaim his old job in a race that drew national attention for its potential impact on two high-profile investigations.

The win means Steele, the first assistant to outgoing District Attorney Risa Vetri Ferman, will continue to oversee the case of Pennsylvania Attorney General Kathleen G. Kane.

He also could be poised to prosecute Bill Cosby.

The embattled entertainer, accused of sexual assault by dozens of women, became an unlikely central figure in the race's waning weeks. In ads and in interviews, Steele and Castor traded attacks over whether Cosby should have been arrested on sexual assault charges in 2005, when Castor led the office.

This summer, Ferman's office quietly reopened the investigation into the decade-old claim that Castor chose not to prosecute. Sources close to the case have said fresh charges against Cosby could come within weeks, although his accuser said she would not cooperate with Castor if he won.

Instead, Steele, a 48-year-old from Lower Merion, will become his party's first district attorney in Montgomery County, reflecting the party's continuing surge there. Democrats have steadily grown in registration over the last decade, and now hold an 8.8 percentage-point lead over the GOP. The victory margin over Castor was about as large.

A career prosecutor, Steele will lead an office of more than 100 lawyers and investigators in Pennsylvania's third largest county.

"You made a choice to take it forward, to fight for victims, to fight for people who have been the subject of crimes," he told a chanting crowd at a victory party in King of Prussia on Tuesday night. "And that is where I will continue to make a difference every day. . . . We're going to take a great office and we're going to make it greater."

His victory came on a day incumbent county Commissioners Josh Shapiro and Valerie Arkoosh, both Democrats, also cruised to reelection, bringing every row office along with them.

"This truly is a historic occasion," said party Chairman Marcel Groen, speaking to the crowd at a Doubletree Hotel in King of Prussia.

Castor wrote an online statement at 11:45 p.m. congratulating Steele and other winners.

"I tried one more time to pull the rabbit out of the hat," he wrote. "This time, the hat was simply out of rabbits."

Despite the attention that the Cosby case brought to the race, voter turnout countywide remained moderate. In interviews before or after they cast their ballots, many voters said that case had little impact on their decisions.

"It's a shame" that Cosby became a campaign issue, said Constance Carrier, 80, of Lower Merion.

She said she voted for Steele because she disagreed with Castor's politics.

"It has nothing to do with whether or not he should have prosecuted Bill Cosby," she said.

Dan West, 48, a Democrat from Bridgeport, said he voted for Castor because he was turned off by Steele's TV ads criticizing Castor's handling of the Cosby case.

"To a very large degree, I thought the ads were distasteful," West said.

Steele's campaign spent more than $92,000 on the ads, saying Castor "was not looking out for victims" when he declined to charge Cosby.

A former Temple University employee, Andrea Constand, had accused Cosby of drugging and molesting her in his Cheltenham mansion, and other women reportedly came forward with similar tales.

Castor said there was insufficient evidence to arrest Cosby in 2005, and fired back with his own ad suggesting Steele could have arrested Cosby when new information became available.

The District Attorney's Office reopened the case in July when a deposition Cosby gave in a civil lawsuit was released, according to sources with knowledge of the investigation.

Ferman, who won a judgeship Tuesday, has neither confirmed nor denied that she reopened the case. The statute of limitations for Constand's accusations will expire in January, as Ferman leaves office.

Several investigators traveled to Toronto in August to interview Constand, said her attorney, Dolores Troiani, and she has agreed to cooperate.

Troiani said her client would not cooperate if Castor were district attorney.

"How can we possibly trust him?" Troiani said.

Constand sued Castor for defamation last week, accusing him of publicly undermining her credibility, misstating facts about her case, and twisting her story to benefit his political ambitions.

Castor called the lawsuit "despicable," and maintained that he would prosecute Cosby if he has the chance.

After his victory Tuesday night, Steele declined to talk about the Cosby investigation except to say: "We are going to continue examining everything."

The Kane case, which he has been overseeing, is likely to draw an equally big spotlight. The attorney general is accused of perjury and other charges in August for leaking confidential grand jury information to a Philadelphia Daily News reporter. She has admitted the leak but denied it was illegal.

Her trial remains months away, though there are efforts underway in the legislature and the Supreme Court to unseat her.

Steele said it was a "hard-fought" campaign.

He said he was looking forward to getting off the campaign trail and back focusing on work in the courthouse, preparing for a Nov. 10 preliminary hearing for one of the perjury charges against Kane, and a murder trial later this month.