The Philadelphia judge who last year said she was sending Msgr. William J. Lynn to prison for enabling "monsters in clerical garb" to sexually abuse children ordered that he could be freed on bail Monday while the state Supreme Court decides whether his conviction was legal.

In a brief hearing, Common Pleas Court Judge M. Teresa Sarmina said she could have made a mistake in allowing Lynn to be prosecuted under the state's child-endangerment law - a decision overturned last week by an appellate court.

"I am, in fact, fallible," Sarmina said. Since the Superior Court ruling Thursday, the judge said, she had been grappling with whether to allow bail for Lynn - and saw no right to keep him in custody. "If the conviction is in question, is not the punishment in question?" she asked.

Imprisoned since June 2012, Lynn, a former top administrator in the Catholic Archdiocese of Philadelphia, could be free next week. He was not at the hearing.

Philadelphia District Attorney Seth Williams has vowed to fight the case to the end. Prosecutors from his office opposed bail, arguing that Lynn was a flight risk and that his conviction might be upheld.

"This case established that people inside the hierarchy of the church could be investigated and prosecuted," Assistant District Attorney Hugh Burns, chief of the appeals unit, said after the hearing. "If this isn't understood, we're losing ground. We're taking a step back."

Lynn's lead lawyer, Thomas A. Bergstrom, who during the historic trial had sparred with Sarmina, said he was impressed by her words and decision.

"She recognized that she had a duty to do the right thing, and I think she did the right thing," he said.

Bergstrom said it could be a week or more before Lynn is freed. Besides posting $250,000 bail, Lynn will be subject to electronic monitoring and weekly reporting, and must surrender his passport.

Asked who would post Lynn's bail, Bergstrom said simply, "We'll get it."

Convicted after a three-month trial, Lynn, 62, was the first Catholic Church official in the country to be tried and imprisoned for crimes related to sex abuse in the church. He has served 18 months of a three- to six-year term imposed by Sarmina, mostly at the State Correctional Institution at Waymart, in northeastern Pennsylvania.

In its ruling Thursday, the three-judge Superior Court panel found that prosecutors and Sarmina misapplied Pennsylvania's child-endangerment law by claiming that Lynn, as the archdiocesan secretary for clergy, was responsible for abuse because he supervised a priest, Edward Avery, who sexually abused an altar boy in the mid-1990s. The court said that the law as written during Lynn's tenure held accountable only those who directly supervised children.

Lynn's defense attorneys contended all along that the monsignor was not properly charged under state law, and in arguments before Sarmina, asked that the charges against him be dismissed. The law was amended in 2007 to specifically include supervisors in positions like the one Lynn had.

Sarmina rejected their arguments before and after the trial, and affirmed her decision in a 235-page opinion. But the higher court called her interpretation of the law "fundamentally flawed."

Williams said the reversal causes harm "in so many ways, to so many people," and hoped the Supreme Court would see differently. In a prior ruling, the justices said the old child-endangerment law could be applied broadly, "in accordance with the common sense of the community," Williams said.

"Lynn's own testimony was that protecting kids from pedophile priests was not just his job, but his number-one job," the district attorney said. "He distributed dangerous pedophiles around the Delaware Valley like so many time bombs, sent them to unsuspecting parishes like wolves in sheep's clothing."

Lynn and his lawyers maintained that only the archbishop had the power to assign or transfer priests. Lynn said he just recommended assignments. He also said he strove to keep abusive priests away from children.

The turnaround in his case - and his looming freedom on bail - stirred new dismay from victim advocate groups.

"Msgr. Lynn's callousness, recklessness, and deceit caused kids to be hurt and predators to walk free," said David Clohessy, director of the St. Louis-based Survivors Network of Those Abused by Priests. "We hope that Pennsylvania's highest court will reinstate his conviction."

Parishioners at St. Joseph's Church in Downingtown, where Lynn served as pastor until his 2011 arrest, were pleased by last week's news, said Msgr. Joseph McLoone, the current pastor. Many were devastated by Lynn's arrest and the scandal that rocked the church.

Many also felt the trial portrayed only one side of Lynn, McLoone said. Parishioners "knew this person as the person who buried their parents, married them, gave their child their first Communion."

"I'm sure there are many people that still pray daily for him," he said.