When Jennifer Zobair sat down to write her first novel, she already had a muse in mind for the heroine, a glamorous, foul-mouthed Muslim woman whose high-profile job in Boston politics is on the line after a terrorist attack.

The character, Zainab, was inspired in part by Muslim political operative Huma Abedin, a longtime aide to Hillary Clinton and vice chairwoman of Clinton’s 2016 presidential campaign. Zainab and her fictional friends struggle to balance their high-pressure jobs with family expectations, like many real-life Muslim girlfriends of the author, an Iowa-born convert to Islam. And although terrorists are central to the plot, Zobair said, she was determined not to let them overshadow the romance.

“I was thinking of people with anti-Muslim views and thought, ‘Can I change that? What would it take?’ ” Zobair recalled in an interview. “Well, it’s got to be love.”

Unfortunately for Zobair, her book, “Painted Hands,” was released in spring 2013, coinciding with the Boston Marathon bombing, in which two radicalized Muslim brothers killed three people and wounded more than 250. Reviewers wouldn’t touch a Muslim love story set in Boston, Zobair said. And so the novel she’d hoped would introduce the unseen lives of ordinary Muslim families got lost in the coverage.

“It was sad because the publicist kept saying, ‘This is a time where people need to read your book, because it’s showing what Muslim American lives are like in a way that people don’t see,’ ” Zobair said.

This unhappy ending is familiar to Muslims across the arts who are struggling to diversify depictions of Islam only to confront hardened stereotypes and a lack of executive support across creative fields. Muslims working in mass media named three common archetypes representing a faith with more than a billion followers: the terrorist “bad Muslim,” the hyper-patriotic “good Muslim,” and the oppressed woman yearning for liberation.

The past couple of years have yielded a handful of breakout moments, but representation of Islam remains overwhelmingly narrow and negative — a problem that’s not only unjust on its own, but one that also stokes anti-Muslim prejudices at home and gives ammunition to jihadist recruiters abroad.

Propaganda tool

“Let’s use our heads here and think about the enemy in this case,” said Jack Shaheen, a media scholar who has tracked depictions of Arabs and Muslims for 40 years. “Every time an American leader or TV show vilifies American Muslims or Arabs, that’s a propaganda tool to say, ‘See what America thinks of you? See how Americans talk about you? We’re ISIL, we love you, come to us.’ ”

During his visit to a Baltimore mosque in February, President Obama noted the “hugely distorted impression” left by programs that show Muslims only in the context of terrorism. “Our television shows should have some Muslim characters that are unrelated to national security.”

Not two weeks after Obama’s remarks, however, “The X-Files” became the latest TV show to cast Muslims as extremists, in this case militants who blow up an art gallery in Texas. Muslim fans vented on social media about what they called gratuitous, nonsensical religious references in the story line.

With the exception of “Quantico,” media critics said, TV shows about federal agents are the worst for pigeonholing Muslims as terrorists. Think “Sleeper Cell,” “24,” “The Agency,” “The Unit” and Emmy-winning “Homeland.”

“It’s hundreds of representations,” said Evelyn Alsultany, director of Arab and Muslim American Studies at the University of Michigan and author of the book “The Arabs and Muslims in the Media: Race and Representation after 9/11.” “We as viewers have been seeing Arabs and Muslims as strange, exotic and threatening for over a century.”

Building a show around a sympathetic Muslim law enforcement agent is no easy task, as the acclaimed writer Dave Eggers learned in an ill-fated pitch for an HBO show about a Yemeni-American cop in San Francisco. Eggers and his partner on the project, the Muslim playwright Wajahat Ali, envisioned “an unusual creation for unusual times that deliberately upended formulaic conventions.”

Competing concepts for the show never meshed and HBO ended up returning the rights to Eggers and Ali at their request. Ali concluded in an essay in the Atlantic that their pilot didn’t work in large part because it defied popular genres in which “the vast majority of American Muslims and the wealth of their diverse experiences have been reduced to stock characters in predictable narratives.”

Until Obama’s comments in February, there had been little national discussion of the issue, save for a flurry of interest in October 2015, when two artists seized the chance to protest depictions of the Middle East and Muslims on “Homeland.” Hired to add graffiti to a “Homeland” set depicting a refugee camp on the Lebanon-Syria border, the artists wrote slogans in Arabic such as “Homeland is racist.”

No one spotted the prank, so the graffiti made it into the broadcast. The story quickly circulated, forcing “Homeland” creators to confront Muslims’ frustrations with the show. “Homeland” producer Alex Gansa expressed grudging admiration for “this act of artistic sabotage.”

Starting a discussion

One of the artists involved, Heba Amin, said she doubts that the incident led to any real soul-searching — and that wasn’t the point.

“The point was to start a discussion that is, in fact, happening, and to shine the light on a show that is totally absurd but obscenely popular,” Amin said. “I think we did our job.”

Rather than wait for the studio, publishing houses and screenwriters to come around, Muslims are taking it upon themselves to flesh out Hollywood’s slim portraits, creating an unprecedented wave of Muslim-produced literary, TV, online and film work.

At Columbia University, the Muslim Protagonist symposium just celebrated its fourth year as a space where Muslims speak openly about the shared, hard-to-articulate feeling of being at once painfully absent from and conspicuously present in mass media.

Literary-minded Muslim students launched the conference in 2012 after their college experience was upended by revelations that they were among the targets of a New York Police Department surveillance operation.

“The NYPD narrative at the time made us so vilified, so the Muslim Protagonist was a way, in my mind, to reclaim our narrative. And the only way to do that is by telling our own stories,” said co-founder Mirzya Syed, who’s working on a memoir. “There’s so much that our community has experienced and it’s a shame that it’s not there in pop culture”

Some Muslim artists put Islam at the center of their projects, while others, such as superstar Zayn Malik — the former One Direction singer whom TV host Bill Maher compared to the Boston Marathon bombers — prefer to keep their faith in the background.

Challenging stereotypes

In a direct challenge to stereotypes about subservient Muslim women, many projects are anchored by strong-willed, independent women.

In the comics world, Kamala Khan, a Pakistani-American teenager with shape-shifting abilities, is the first Muslim heroine to assume the Ms. Marvel title and the first Muslim superhero to headline a major comic book series.

In gaming, where favorites such as “Call of Duty” are notorious for vilifying Islam, an entertainment company bankrolled by a Saudi prince is developing “Saudi Girls Revolution,” a mobile game and digital series about seven Saudi warrior women.

And two Muslim women who wear headscarves, or hijabs, made ripples in reality TV: Amanda Saab on “MasterChef” and Aidah (her last name wasn’t publicized) on “Home Free.” On social media, Muslim viewers rejoiced that the shows focused on their abilities, not their faith.

“There are bright spots,” said Alsultany. “But I do feel like the efforts that have been made brought no real impact, as we see now with the hateful rhetoric. It’s just stunning.”

The slow evolution in roles can be seen in the USA Network’s “Mr. Robot,” in which an Egyptian-American actor plays a computer programmer. The one obviously Muslim character is Trenton, an Iranian-American woman whose role is written to focus on her hacking skills.

The show’s Egyptian-American creator, Sam Esmail, thanked his family in Arabic when “Mr. Robot” won this year’s Golden Globe Award for best TV drama. Muslim fans delighted in hearing the language of the Qur’an broadcast on national television.

“Just wait till I win my Golden Globe and I yell, ‘Allahu akbar!’ ” said comedian and “Daily Show” regular Aasif Mandvi. “I’m so ready!”