As her detectives zeroed in on a sitting county commissioner, Montgomery County District Attorney Risa Vetri Ferman knew she would eventually have to answer a few uncomfortable questions about the case.

Could she objectively investigate fellow county officeholder James R. Matthews? Did her past ties to Bruce L. Castor Jr. - Matthews' avowed enemy and Ferman's former boss - influence her decision to press charges?

"There were accusations circling, there was distrust mounting in the government. Someone had to look at what was happening and bring some clarity," Ferman said Tuesday as she announced Matthews' arrest on charges of perjury and false swearing.

But days later, those questions have lingered, and the case has drawn some of the most intense scrutiny the Republican prosecutor has encountered yet in her government career.

"Risa wouldn't be district attorney if it weren't for Bruce," said Commissioner Joseph M. Hoeffel III, a Democrat. "This is the textbook definition of conflicts of interest and being too close politically."

To Ferman's critics, the 69-page grand jury report in the case, with its included suggestions for reform, reads like a political manifesto drafted by a district attorney overstepping the bounds of her office. What's more, they said, Ferman's perceived political ties to Castor could ultimately pose problems for the criminal case.

Her supporters counter that the case exemplifies why Ferman has become such a popular prosecutor. They say the investigation demonstrates her fearlessness in taking on even the county's most powerful people.

Matthews is accused of lying to a grand jury in October about his previous business relationships with a title-insurance firm that received government contracts.

But the scathing grand jury report went further, alleging the three-term commissioner had misspent campaign money, recklessly wasted taxpayer money, and awarded contracts and plum positions to friends and political supporters.

The jurors described Matthews' behavior as "appalling," but ultimately decided none of his purported misdeeds - outside of his alleged perjury - violated state law.

'This is totally silly'

In the days since Matthews' arrest, he and Ferman have declined to comment, saying both sides were seeking a judicial gag order. But the commissioner has left little ambiguity about his opinion of the matter.

"This is totally silly," he said as he was ushered into a courtroom Tuesday. In comments quoted in the grand jury report, he insisted the investigation was "politically motivated" and driven by Castor.

"They're out to get me," Matthews is quoted as saying.

The prickly relationship between Matthews and Castor, fellow Republicans, goes back years.

In 2007 - days after both were elected to the county Board of Commissioners - Matthews struck out on his own, formed a power-sharing deal with Hoeffel, and effectively edged out Castor - the race's top vote-getter and a former district attorney. The county Republican Committee reacted by censuring Matthews for "betrayal of the voters' will."

It is clear - or so Ferman's critics say - that Castor turned to his protege, Ferman, to settle the score.

Ferman had served as Castor's first assistant district attorney before she was elected to the office in 2007. Since then, she has endeavored to exhibit her independence from her predecessor.

Targets of Castor

Even so, portions of the grand jury report read as though Castor could have written them.

Every issue raised within its pages - from Matthews' purported spending of campaign cash on personal expenses to his cozy relationship with the Ohio insurance-regulating company CBIZ, which donated to Matthews' campaign and received a county contract worth millions - had been targets of Castor's criticism at public meetings and in the news media.

"Out of the three commissioners, the only person that was not negatively mentioned in the report was Castor," said Jeffrey Lindy, Hoeffel's attorney. "It is improbable in any reasonable view that two out of three commissioners are horrible but one is above reproach."

Although Castor maintains he never had direct contact with county detectives or with Ferman's office until the grand jury subpoenaed him earlier this year, he conceded Thursday that his frequent public jabs at his rival were intended to draw law enforcement scrutiny.

It seems to have worked. Again and again, the grand jury said in its report that it either relied upon or was directed by newspaper accounts in investigating Matthews' dealings.

"All I did was call these things to the attention of the reporters in the room," Castor said Thursday in an interview. "The investigation was totally driven by the news coverage."

But it doesn't matter where the initial reports come from, said a neighboring county's top prosecutor. They could be from newspapers, enemies, allies - Ferman was still right to check them out, Bucks County District Attorney David Heckler said Thursday. As the county's chief law enforcement officer, that was her duty, he said in an interview.

State law gives district attorneys an important option: They can pass off politically sensitive investigations to the state Attorney General's Office. But the Pennsylvania District Attorneys Association offers no guidelines to its members on what factors to weigh in making that decision, executive director Richard W. Long said.

Heckler, a Republican, declined to comment specifically about the Matthews case, but said he, too, had grappled with such decisions over the last year. He caught critical flak in February for not referring to state investigators a probe into former Bucks County Register of Wills Barbara Reilly's use of employee time for political purposes.

But Heckler also fought off complaints in April when he disqualified his office from investigating allegations lodged against Bucks Sheriff Edward J. "Duke" Donnelly. Heckler's reasoning: He and Donnelly had run on the same political slate. (The Attorney General's Office declined to press charges in that investigation.)

No prosecutor can afford to be perceived as playing favorites, Heckler said,

"The paramount concern is that the public has confidence in the system at the end of the day," Heckler said Thursday. As a prosecutor, "your determination should be based on the facts of the law and nothing else."

Contact staff writer Jeremy Roebuck at 267-564-5218, jroebuck@phillynews.com, or @inqmontco on Twitter.