WICHITA — The prosecution’s story goes like this: Three men in rural Kansas were so driven by racist hatred that they spent months ahead of the 2016 presidential election plotting to kill as many Muslims as possible.

The defense attorneys’ version is about a scheming FBI and a manufactured plot pinned on three unsuspecting men who happen to love guns, the Constitution and American freedom.

Sixteen jurors, who listened to those tales in a federal courtroom in Wichita on Thursday, will ultimately have to decide which narrative to believe. Three members of a west Kansas militia — Patrick Stein, Curtis Allen and Gavin Wright — are charged with conspiring to bomb a building housing Somali Muslim refugees and a mosque in the town of Garden City, Kan. All three have pleaded not guilty.

Their trial promises to invoke some of the most divisive themes of the 2016 campaign and the subsequent Trump era, touching on patriotism, freedom of speech, terrorism, immigration and the right to bear arms.

“Keep in mind with what this case is about and what it isn’t about,” federal prosecutor Risa Berkower said during opening arguments Thursday. “The defendants are not charged with any crime because of their opinion about Muslims.”

They’re on trial, she said, because they were planning “to kill as many men, women and children as they could in that complex, because they wanted to kill Muslims.”

In his opening argument, defense attorney Richard Federico denied that claim, calling the bomb plot a setup orchestrated by the FBI during a 10-month investigation. While their clients expressed ideas that were shocking and offensive, defense attorneys argued that they never would have approached the point of violence had it not been for the prodding of the FBI and its undercover informant.

They argued that there’s nothing illegal about being in a militia or owning a collection of firearms, as lots of people in Kansas do. They’ll argue that even with the hours of recorded conversation, their clients never fulfilled the legal requirements of a true conspiracy, that it was all “idle” talk. And they’ll call on character witnesses, including Wright’s and Allen’s brothers to vouch for them.

“Idle chatter? Sure. Bluster? Words of hatred? Yes. Some of that locker room talk? Some of that’s there, too,” Federico said. Regarding the FBI, he said, “You’re going to hear them talking and plotting about how they’re going to move this along.”

The case against the three men who called themselves the “Crusaders” burst into the open in October 2016, when FBI agents stormed the trailer homes of Allen and Wright in the plains outpost of Liberal, Kan., and a modest farmhouse where Stein’s parents lived in the hamlet of Wright, Kan.

The agents had been monitoring all three men for months and recording their conversations with the help of a paid informant. But their investigation came to a halt when Allen’s girlfriend called the police with an assault allegation and told them about the plot. From the defendant’s properties, investigators hauled away weapons, ammunition, computers and documents, as well as chemicals, beakers and other tools they allege the men were using to build a bomb.

“It really shocked everyone,” Tammy Barlow, a bartender at the Veterans of Foreign Wars hall in Liberal, said this week. Barlow regularly served beers to Wright and Allen. “Gavin was always so polite,” she said. “No one had any idea they had that other thing going on.”

That other thing, Berkower argued in court Thursday, amounted to a plan not just to commit mass murder but to “send the message that Muslims were not welcome here” and to “inspire” other Americans to do the same.

“The only f---ing way this country’s ever going to get turned around is it will be a bloodbath,” Stein was recorded as saying, transcripts show. “The only good Muslim is a dead Muslim,” he said at another point.

Prosecutors say the men brainstormed methods of attack, including murder, kidnapping, rape and arson. They met in an open field or played music during their indoor meetings to avoid detection. They communicated on a walkie-talkie phone app, using nicknames for one another such as “Commander,” “XO” and “Sparky” and throwing around military lingo such as “Roger that” and “10-4.”

Prosecutors say the men discussed possible targets including Muslim residences and mosques — “during prayer time,” Wright allegedly suggested — as well as public officials, churches and landlords who have given refugees safe haven. They ultimately settled on a Somali-populated apartment complex in Garden City, an hour north of Liberal. They conducted surveillance. They gathered chemicals. They printed out thousands of pages from the Internet, including recipes from “The Anarchist Cookbook.”

“They did extensive research,” Berkower told the jury. “They developed a detailed plan. They learned how to make explosives. They practiced making explosives. They actually made explosives.

“They even made an explosives shopping list,” she said: “Blasting caps, C4, hand grenades, 40 mm mortar rounds.”

During the trial, which is expected to last more than a month, prosecutors will attempt to prove that Stein, Wright and Allen intended to carry out the threats they made while under surveillance and that their actions were criminal, not legal, expressions of their First and Second Amendment rights. Defense attorneys plan to condemn the men’s hateful speech while arguing that, in the United States, a person can hate someone without breaking the law.

Stein is someone who “at times has allowed his prejudice and hate to consume him,” his attorney, Jim Pratt, told the jury Thursday. Pratt acknowledged that Stein called Muslims “cockroaches,” that he bought into the divisive rhetoric of the 2016 presidential election cycle and that he verbalized his fury at a time when “hate ruled the day.”

By the end of the trial, Pratt told members of the jury that they probably won’t like his client. But, Pratt said, “you will need more than a dislike of Patrick Stein to find him guilty.”

Julie Tate in Washington D.C. contributed to this report.