Attorney General Kathleen G. Kane said she was "cautiously hopeful," and answered virtually no other questions.

Then, Pennsylvania's first female attorney general took a long, slow walk out of City Hall on Wednesday, surrounded by a swarm of reporters and cameras.

Kane, the first elected Democrat to hold the second-most-powerful statewide office, had just emerged from a back row in a Supreme Court courtroom, where she listened as lawyers presented oral arguments in a case whose outcome could spare her from, or condemn her to, criminal prosecution.

A ruling could be days or weeks away as the panel of three Republicans and two Democrats considers the matter.

Remarks by Chief Justice Thomas Saylor, a Republican, suggested that he may already have taken a side.

From the bench, Saylor suggested that the grand jury probe of a leak from an old investigation of a Philadelphia civil-rights leader was launched legally. Kane has insisted it was not.

"There's a lot of authority for Judge [William] Carpenter to do what he did," Saylor said.

He spoke as Thomas E. Carluccio, the special prosecutor whose work led to recommended criminal charges against Kane, was arguing in defense of his own appointment by Carpenter, a Republican Montgomery County Court judge.

After seven months of hearing testimony from Kane and most of her top aides, the grand jury led by Carluccio in December urged the Montgomery County district attorney to charge Kane with perjury, official oppression, and other offenses. Kane has denied breaking the law.

In January, the high court forbade District Attorney Risa Vetri Ferman, a Republican, to take action until it ruled on Kane's appeal. If Kane wins, the recommended charges could disappear.

On Wednesday, Kane's lawyer, Joseph Del Sole, argued that Carluccio's appointment and the resulting proposed charges against Kane were the product of an illegal process.

He said this was because Carpenter, upon learning that secret material about an investigation into former Philadelphia NAACP head J. Whyatt Mondesire had made its way into the Philadelphia Daily News in 2014, did not follow lawful protocol.

The Mondesire probe was conducted in 2009 by a statewide grand jury in Norristown that has finished its work.

Because that grand jury was disbanded years ago, Del Sole said, Carpenter had no legal ground to appoint a special prosecutor with broad powers to investigate the leak.

The proper procedure was to "send it to a district attorney or the attorney general and then let them proceed," said Del Sole, a former state appellate judge.

Carluccio said the issue of whether a grand jury's term had expired was irrelevant.

Separately, he added, prior cases before the high court have established Carpenter's right to do exactly what he did.

In 2008, the Supreme Court found that it was lawful for a Dauphin County Court judge to appoint a special prosecutor to determine who had leaked information. That case dealt with a grand jury investigation into whether a casino owner lied about ties to organized crime.

Carluccio's reference to this case, which forms the spine of his argument, prompted Saylor to express his agreement from the bench.

Kane's lawyers disagreed. There is no special statute that authorizes judges to appoint special prosecutors, they said. A state law that once did so has expired, and the high court itself nullified a special prosecutor's appointment in a 1962 opinion, her lawyers have said.

The debate was vigorous and prompted questions from all four other justices.

"You seem to me to say, 'I don't understand why we're here. Judge Carpenter and I had absolute, unlimited power. We're dictators ... in a benign conspiracy,' " Justice Max Baer, a Democrat, said to Carluccio. "Do you think there is any limit as to what you can do?"

Justice Correale Stevens, a Republican, noted more than once that Carpenter himself might have been unconvinced of his authority to appoint a prosecutor in the matter.

The judge referenced a May 2014 letter in which Carpenter informed then-Chief Justice Ronald D. Castille that he would be appointing a special prosecutor.

"Please advise if you feel that I am in error or have exceeded my authority as the Supervising Grand Jury Judge" Carpenter asked.

Castille never replied but has made it plain in interviews that he backed Carpenter's action.