Riz Ahmed in the HBO series “The Night Of.” (Barry Wetcher/HBO)

The British actor Riz Ahmed offers a simple explanation for why the Islamic State militant group keeps finding recruits:

Terrorists make better TV.

Specifically, the actor told the British Parliament last week, extremists sell heroic story lines to youths from minority communities who are too often cast as bit players or villains in their home countries.

“In the mind of the ISIS recruit, he’s a version of James Bond,” Ahmed said, using an alternative acronym for the Islamic State. “Have you seen some of these ISIS propaganda videos? They’re cut like action movies. Where’s the counternarrative? Where are we telling these kids that they can be heroes in our stories?”

Parliament had invited Ahmed to speak about diversity — a word he rejected because it sounded like “a little bit of spice” sprinkled onto a mostly white entertainment industry. Instead, he warned that the industry’s failure to speak to minorities could prove fatal when a shadow film industry run by terrorists churned out slick propaganda made just for them.

The actor directed most of his criticism toward the British film industry and its penchant for “all-white period dramas.” But his experience in the United States hadn’t been all rosy either.

“I’m getting on the plane to L.A. to attend the ‘Star Wars’ premiere, and I still get that second search before I board,” said Ahmed, who played the pilot Bodhi Rook in “Rogue One: A Star Wars Story” last year.

Growing up in a Pakistani Muslim family in Britain, he recalled his mother yelling “Asian!” every time someone who looked vaguely like him appeared on TV.

“Every time you see yourself in a magazine or a billboard, TV, film, it’s a message that you matter,” Ahmed told Parliament.

Ahmed said he nearly turned down drama school. “I didn’t think there was any future in my playing ‘Cabdriver number two,’” he said.

Instead, he said he lucked into roles that jettisoned Muslim stereotypes, like a student falsely accused of murder in HBO’s “The Night Of.” Or roles that parodied those stereotypes, like his portrayal of the incompetent Islamist militant Omar in 2010’s “Four Lions.”

In the Guardian last year, Ahmed contrasted the British film industry “and the myth we export of all-white lords and ladies” with a more-inclusive Hollywood. “American society is pretty segregated,” he wrote. “But the myth it exports is of a racial melting-pot, everyone solving crimes and fighting aliens side by side.”

The world needs more of that, he told Parliament on Thursday.

“Everywhere the old order is in flames,” he said. “Whether in film and television with the advent of streaming and the globalized market place. Whether at the ballot box with the ascendance of populism.”

In 2015, The Washington Post spoke to filmmakers who had been inside the Islamic State’s slick propaganda machine, which had advanced well beyond the crude videotapes of al-Qaeda.

“What they described resembles a medieval reality show,” the reporters wrote. “Camera crews fan out across the caliphate. … Battle scenes and public beheadings are so scripted and staged that fighters and executioners often perform multiple takes and read their lines from cue cards.”

The United States and its allies are trying to counter those stories but have so far failed, Ahmed said in his speech.

“It’s a noble failure,” he said. But a very dangerous one “when centrifugal forces are threatening to tear us apart.”

“If we fail to represent people in our mainstream narratives, they’ll switch off,” he said. “They’ll retreat to fringe narratives, to filtered bubbles online, and sometimes even off to Syria.”

More reading:

This ISIS defector said he was an innocent bystander. A new video questions his story.

Don’t lower your standards: ‘Rogue One: A Star Wars Story’ is a huge disappointment