TORONTO — A judge has quashed polygamy charges against two leaders of a polygamous community in western Canada.

The judge said Wednesday the province's attorney general did not have the authority to appoint a second special prosecutor to consider the cases of Winston Blackmore and James Oler after the first special prosecutor recommended against charging the two men.

Authorities arrested Blackmore and Oler, who lead rival polygamous factions in Bountiful, a town in southeastern British Columbia, in January. Blackmore was charged with marrying 20 women and Oler was accused of marrying two women.

Blackmore, long known as "the Bishop of Bountiful," runs an independent sect of about 400 members in the town of Bountiful. He once ran the Canadian arm of the Utah-based Fundamentalist Church of Jesus Christ of Latter-day Saints, but was ejected in 2003 by that group's leader, Warren Jeffs.

Oler is the bishop of Bountiful's FLDS community loyal to Jeffs. Even though many of the town's residents are related or have same last name, followers of the two leaders are splintered and are not allowed to talk with each other.

British Columbia Supreme Court Judge Sunni Stromberg-Stein said the appointment of the second special prosecutor — and therefore the decision to charge the men — was "unlawful."

The men had petitioned the court to drop the charges, arguing that the attorney general had gone "special prosecutor shopping" until he found someone who would go ahead with charges.

"I am thrilled," Blackmore said in a telephone interview with The Associated Press. "It has been a long and hard year so far. It's been very stressful for my family and stressful for me."