A judge has temporarily banned from the pulpit a pastor who confessed to having sex with church members and neglecting to tell them he had AIDS.

Montgomery County Circuit Judge Charles Price ruled yesterday on a preliminary injunction sought by deacons and trustees of Shiloh Missionary Baptist Church against the Rev. Juan McFarland.

Price heard arguments Thursday morning in a lawsuit filed by deacons and trustees of the church, who want McFarland removed as the church's leader. They said that the congregation voted to fire him Oct. 5 but that he refused to step down, had the locks changed on the church and had names changed on bank accounts.

McFarland, pastor at Shiloh for 24 years, attended the hearing without an attorney and had no comment inside or outside the courtroom.

The boards of deacons and trustees are suing McFarland and church parliamentarian Marc Anthoni Peacock, who was involved in changing the locks and bank accounts.

One of the plaintiffs, Deacon Nathan Williams Jr., said that that in August and September, McFarland delivered sermons during which he confessed to having sex with church members in the church building, but not in the sanctuary, having HIV but not telling sex partners, and using illegal drugs.

He testified that the congregation first tried to help the pastor but that when it didn't work, members took a vote during a service Oct. 5 to fire him.

Peacock testified that the meeting wasn't officially called as part of the Sunday service and described it as "holy hell."

Price said the courts have no role in religious matters, but they sometimes have to step in when congregations can't settle their differences over control of buildings and money. "If it could be resolved in the church, it would have been already," the judge told the courtroom packed with more than 100 people.

The court case centers not on the pastor's confessions but on church bylaws adopted in January 2013. They say pastors can't be fired and can leave only through resignation or death. The bylaws also give pastors the authority to fire church leaders.

Williams, who was fired by McFarland from his position as chairman of the board of deacons in September, said that bylaws were not properly adopted and that the church members voted 80-1 to rescind them Oct. 5, the same day they voted to fire the minister.

Peacock said the bylaws were properly adopted. "Everyone was happy-go-lucky with it," he said.

Shiloh Missionary Baptist Church was founded more than 90 years ago and is part of the National Baptist Convention. Church members on both sides of the pastoral dispute said the convention gives churches autonomy in personnel decisions.

The Associated Press contributed to this report.