CHICAGO — A former sheriff’s deputy accused of being the ringleader in the bombing of a Minnesota mosque emerges in court documents as a sometimes-threatening figure with anti-government views, but also as a person with enough intelligence and charisma to write books and woo others into his shadowy group.

Michael Hari, 47, allegedly intended for the attack to scare Muslims into leaving the U.S. He and two associates were charged Tuesday with traveling some 500 miles (805 kilometers) from rural Clarence, Illinois, to carry out the Aug. 5 pipe-bomb assault on the Dar Al-Farooq Islamic Center in Bloomington, Minnesota. The explosion caused a damaging fire just as morning prayers were about to begin, but no one was hurt.

Even before his arrest, the self-described entrepreneur and watermelon farmer had a background that included working in law enforcement, floating ideas for a border wall with Mexico, fleeing with his daughters to central America during a custody dispute and suing the federal government for allegedly cutting in on his food-safety business.

Court papers say Hari promised his accomplices $18,000 for their participation in the mosque attack. But the complaints in the case do not portray him as well off, citing an informant who said Hari frequently had to stay at his parents’ home because he had no running water or electricity.

Hari describes some of his political views in a federal lawsuit he filed just last month against the Department of Agriculture in which he complains it was cutting in on his food-safety certification business, Equicert.

“The People of the United States have rejected the Marxist doctrine that the government shall own the means of production,” he wrote.

He spoke to the Chicago Tribune last year for a story on Illinois residents seeking contracts to help build the border wall with Mexico championed by President Donald Trump. Hari said he had drafted a $10 billion construction plan.

In addition to Hari, authorities charged Joe Morris, 22, and Michael McWhorter, 29. All three men live in Clarence, a community with a population of just a few dozen people encircled by farm fields. During a reporter’s visit on Wednesday, at least four homes displayed Confederate flags — one flying high atop a flagpole in a front yard.

It isn’t clear why the men targeted a mosque in Minnesota, though Al-Farooq had been in the headlines in recent years.

A group of young Minnesota men who were convicted of conspiring to travel to Syria to join the Islamic State Group had frequented the mosque. A young woman and at least one of the men who successfully got to Syria also worshipped there. Mosque leaders were never accused of any wrongdoing.

Hari fled the U.S. in the 2000s to live in Mexico and then the small South American nation of Belize, taking his two teenage daughters with him for fear his ex-wife would gain custody, according to media reports of legal proceedings against him after he returned to the U.S. in 2006. He was convicted of child abduction and given probation.

The case put Hari on television.

Dr. Phil McGraw of the “Dr. Phil” talk show used an investigator to help track down Hari in Belize, shortly before Hari returned to face charges of abducting his kids.

He wrote a handful of self-published books, including essays on religion. One was titled “Resurgence: More than Conquerors.” Another was “Beowulf: A Novel of the Norsemen,” which was listed as the first in a series.

Hari belonged to the Old German Baptist Brethren, a religious sect that shares some beliefs of the Amish, although its followers do not spurn modern technology, according to 2006 coverage of his trial published in the Champaign News-Gazette.

Some of Hari’s neighbors in Clarence said he frightened them. Hope O’Neil described to Champaign television station WCIA how Hari once put a gun to her husband’s head when they complained that Hari’s horse kept wandering into their yard. Another neighbor agreed, saying Hari gave her “the heebie-jeebies.”

Hari was raised near Champaign and went to graduate school in criminal justice at the University of Central Texas, where he took courses in security-related construction, the Tribune reported.

The three men are also suspected in the attempted bombing of an abortion clinic on Nov. 7 in Champaign, about 140 miles south of Chicago, according to the U.S. attorney’s office in Springfield. In that attack, a pipe bomb was thrown inside but failed to go off.

A tip in December led authorities to investigate the three men, after a person sent the local sheriff photos of guns and bomb-making material inside Hari’s parents’ home. In January, a second informant told authorities that the three men had carried out the mosque bombing and the failed clinic attack, according to the complaints.

The suspects broke a window to the imam’s office and threw a pipe bomb containing black powder into the mosque. The bomb exploded, causing a fire that was extinguished by sprinklers, according to an affidavit.