On a rainy afternoon in early April at Boston’s largest mosque, the sheikh in the seersucker suit was in his office, offering comfort and advice.

To a young student wondering if he should get engaged: “Aw, man, just go for it!”

To a middle-aged man agonizing over how to care for his dying father: “You should preserve life as best you can.”

To a sobbing young woman who told him about problems at home: “I have someone who can help you, a Muslim counselor. . . . Let’s talk about fixing it.”

Days later, bombs exploded on Boylston Street. And the unlikely face of the Muslim community in its time of crisis became this 6-foot-5-inch, blond-haired, blue-eyed former hip-hop DJ whose grandfather was a fundamentalist Christian preacher.

William Suhaib Webb, imam of the Islamic Society of Boston Cultural Center in Roxbury, has been a target of conservative Muslims on the Internet, who call him a sellout, and of other critics who say he is an extremist.

He has tried, for better or for worse, to respond to all of it — in his sermons, on CNN, on Twitter. At the same time, he has endeavored to improve the mosque’s relationships with Jewish and Christian leaders in Boston.

“I’m just exhausted,” the 40-year-old Webb said, sipping a flask of coffee in his book-lined office overlooking the busy intersection of Tremont Street and Malcolm X Boulevard. “I don’t have days anymore. I just have . . . smears.”

Webb, who memorized the Koran while living with his parents in Oklahoma and became an advanced Islamic legal scholar after years of study in Cairo, has in recent years become among the most famous imams in America.

He has 34,000 Twitter followers and a “virtual mosque” website that gets some 13,000 page views a day. In his sermons and in social media, Webb — many followers call him “sheikh,” an honorific for a respected teacher — toggles effortlessly between English and Arabic, dropping words like “baller” and references to “The Walking Dead,” a television show about zombies, into exegeses of Sufi poetry.

When he came to the cultural center 18 months ago, he faced significant challenges. He had to connect with immigrants from all over the world, as well as their US-born children and converts from other faiths. He also had to be a bridge to the city’s other faith communities, someone who could help the city move beyond concerns, particularly among some Jewish leaders, that the mosque’s leadership had extremist ties.

Webb, for his part, had his own big plan — to establish one of the first Muslim seminaries in the country. He wanted to nurture a new generation of American imams and Muslim women scholars — orthodox, but culturally conversant and civically involved — and to educate more casual students about their faith.

The Marathon bombings cast Webb and his mission into a crucible. In the media, Islam was on trial again, and Webb was, too.

* * *

Webb grew up outside Oklahoma City. His grandfather, the preacher, was a strict conservative — no dancing, no shorts. His parents are what he calls “post-Woodstock Christians,” more accommodating of modernity.

He has positive memories of church, “fellowship with great, wonderful people.” But he could never get his head around Jesus. What color was the son of God? How could God choose a race for himself when he assumed human form?

By his late teens, Webb was popular figure in the Oklahoma City hip-hop scene, a pot-smoking DJ with a gang affiliation. Once, he says, he found himself in a car during a drive-by shooting.

Abdulsamad Frazier, a close friend from those days, remembers Webb as friendly and generous, though he kept dangerous company.

“If anybody in the neighborhood messed with him, he would hold his ground,” Frazier said. “He hung around with some major guys, guys who were real serious guys.”

But Webb was unhappy, searching. He began learning about Islam through friends in the hip-hop world. Curious, Webb checked a copy of the Koran out of the library.

To his surprise, it mentioned Jesus and Mary. But it resonated with him in a way the Gospels never had. It was 1992, the year of the Rodney King riots in Los Angeles.

“The idea that God is not a human being, God is not a color — that was what I was looking for my whole life,” he says now.

Imam William Suhaib Webb had dinner last week with a friend, Adeel Khan. Many of Webb’s followers call him “sheikh,” an honorific for a respected teacher.

He was 20 years old, a college freshman at the University of Central Oklahoma about to pledge Alpha Phi Alpha, a historically African-American fraternity. He became an observant Muslim instead.

His parents — his mother worked in human resources, his father was a history professor — were greatly relieved that he had changed directions, but they found his new religious fervor baffling and unsettling.

“We were disappointed,” said his mother, Mary Lynne Webb, who is close with her son and proud of him now. “We felt like we were kind of failures, I guess.”

Webb finished a degree in education, devoting his free time to Islam. Four days a week, he traveled to Norman, Okla., to study with a Senegalese sheikh. It was a lonely period, though over the next several years, others from the music scene converted, too.

When Oklahoma City opened its first mosque a few years later, its community chose the 26-year-old convert as its imam. Imad Enchassi, then a mentor of Webb’s and now the senior imam of the Islamic Society of Greater Oklahoma City, said the decision was almost unanimous.

He said Webb instinctively related to young people, but he won over the older crowd, too.

“He would sit down with elders on the ground; some elders would eat with fingers, he would do the same thing,” Enchassi said.

But Webb, looking back, gives himself a grade of D-minus for his work as a young imam. “I was still finding myself spiritually,” he said. “I gave a lot of hot sermons. They probably weren’t very good. I didn’t have enough scholarship.”

The Bay Area chapter of the Muslim American Society, a national grass-roots religious and cultural group, spotting a rising star, offered to fix that by sending him to Al-Azhar University in Cairo, one of the world’s leading centers of Sunni Muslim learning. With his wife, Asmah Ayob, who was a Malaysian anthropology student when he met her in college, Webb moved to Cairo.

After a brief stint in California upon his return in 2010, he learned the Islamic Society of Boston Cultural Center in Roxbury was looking for an imam.

* * *

A dominant theme of Webb’s ministry is that Muslims can live faithful lives in contemporary America, and that they also have an obligation to participate — civically, culturally, and politically.

One of the first classes for the community at Webb’s fledgling educational institute is called Getting It Right. More than 200 people pack the Sunday night lectures, which emphasize balance, service, self-discipline, love.

Kamran Ahmed, a 24-year-old medical student, said Webb drew him to the mosque.

“It doesn’t become this abstract philosophical discussion,” he said. “It becomes this discussion of when this thing happened at work, or this thing happened at school, this is how the Prophet, peace be upon him, would have responded.”

The Ella Collins Institute — scheduled to begin training seminary students in the fall and named for Malcolm X’s older half-sister, an educator and civil rights activist who eventually became an orthodox Sunni — is Webb’s attempt to help answer a twofold problem facing America’s Muslim community. There are too few qualified imams, and those who are here tend to be immigrants trained overseas who have difficulty understanding the lives of American youth.

Amid teaching and ministering to the mosque community — 700 to 1,000 people show up for Friday prayers — Webb feeds content to his “virtual mosque” and tweets constantly.

The mosque has taken on new projects, like the development of a health care team, which assesses the needs of the congregation and the neighborhood around it, and offers screenings and referrals.

Webb also maintains a frantic pace on the speaking circuit; just before the bombings, he was the Muslim representative in a cordial interfaith discussion about American religion on CBS’s “Face the Nation.”

“You’re never here,” a teenager who came to his office hours one recent Friday lamented.

Home has offered little reprieve from the intensity. His wife and two school-age children are living in Malaysia for the next several years — in order, he says, to be closer to his in-laws and to expose the kids to Malaysian culture. Though they Skype twice a day, he is lonely without them.

The demands have been so great that, in early April, Webb said he thought he could last only about five years as an imam. After that, he said, he hoped to devote himself to the Ella Collins Institute.

And yet, in an interview on that quiet morning, Webb said he had fallen for Boston.

“My neighbors in Dorchester call me the eye-mamm,” he said, with a laugh. “I didn’t know about this whole, you have to move your car on Fridays [for street cleaning]. They come banging on my windows, ‘Eye-mamm, eye-mamm! You got to move your car!’ ”

“I feel it’s a cozy city,” he said. “It’s a cozy city.”

* * *

On Marathon Monday, Webb was in Detroit, where he had given a speech the night before. The text messages began — at first one or two, then “a waterfall.”

“Are you in Boston?” “Are you OK?” “Pray for Boston.”

“Im sad im not in Boston,” he tweeted that afternoon. “My heart is with you.”

And: “If any marathon runner needs a place to stay, my house is open.”

Flying home that night, Webb thought, along with so many other Boston Muslims: I hope it was not someone claiming to represent Islam.

The next day, the imam and his staff flew into action, planning a vigil, rallying volunteers, setting up trauma counseling. Upon learning later in the week that the bombing suspects were Muslims, Webb condemned the attacks, calling the suspects “criminals and enemies of society” and disassociating Islam from their acts.

At prayer times, Webb and his staff asked congregants to share with the FBI any information they had about the suspects and offered help with legal counsel if they needed it. Hate mail poured in — but so did letters of support, buoying Webb’s spirits.

Webb was disappointed, though, when, two days after the bombings, the governor’s office organized an interfaith service to be attended by President Obama. Webb says he was asked to speak, but he was removed from the program the night before.

The service at the Cathedral of the Holy Cross featured the Roman Catholic archbishop, the Greek Orthodox hierarch, the rabbi of the city’s largest synagogue, and senior pastors of major African-American, Hispanic, and mainline Protestant churches.

Muslims were the only faith community not represented by a cleric. Instead, Nasser Weddady of the American Islamic Congress, a civil rights organization, offered a reflection. Webb was in the pews, as were several other prominent imams.

Webb said he was never given an explanation. The governor’s press office said, in an e-mail to the Globe, that organizers “were not able to accommodate everyone on the speaking program, but are proud of the speakers we had.”

Webb praised Weddady’s speech, but he was clearly stung. On Twitter, he told indignant community members to focus on honoring the victims; later, he said, the community could raise questions about the choice of speakers. He said the issue was not about him — there were other Muslim religious leaders, such as Imam Talal Eid, the widely respected Muslim chaplain at Brandeis University — who could have offered the reflection instead.

Meanwhile, Webb came under attack online; some Muslims asked why he would speak well of the president, whom they called a “war criminal.” Others questioned his quick condemnation of the bombing suspects, the Tsarnaev brothers.

After he said publicly he would not pray over the body of Tamerlan Tsarnaev, some Twitter followers reproached him for refusing to bury the suspected terrorist’s body — even though, as Webb tried to explain, that was a different issue and in any case the mosque has no graveyard.

“I find it odd that people who claim to be so religious have the time to attack those working hard under duress,” Webb tweeted April 22.

The heightened focus on Boston’s Muslim community offered an opportunity for Charles Jacobs, a longtime critic of the cultural center and its sister mosque in Cambridge (they are both owned by the Islamic Society of Boston but run separately), to revive his allegations — picked up by USA Today — that the mosques are breeding grounds for hatred and extremism.

Writing in his column in the Jewish Advocate newspaper and on his website, Jacobs suggested that Webb was disinvited from speaking at the interfaith service because organizers feared he was an extremist. He charged that Webb was surreptitiously teaching a curriculum promoted by the Muslim Brotherhood that “teaches vicious hatred and calls for young Muslims to engage in Jihad against non-Muslims in order to establish a global Islamic state.”

“We think he is being publicly dishonest,” Jacobs said of Webb in an interview.

To the imam, the notion was ridiculous.

“I don’t have any private classes . . . where we meet in some bat cave and we lay out blueprints of how to conquer America,” he said.

The charge made just as little sense to outside observers. Todd Helmus, a senior behavioral scientist with the RAND Corporation who has worked extensively on counterterrorism, said Webb’s virtual mosque is one of the more active and influential Muslim voices against radicalism in the country.

“The problem isn’t Suhaib Webb. The problem is there aren’t more imams like Suhaib Webb,” he said.

And Diana Eck, a Harvard professor who teaches a case study of the saga of Jacobs and Boston’s mosques, said Jacobs’s argument that Webb and other moderate Muslims are operating a “stealth jihad” movement belies logic and evidence.

“For years, they were asking, ‘Where are the moderate Muslim voices?’ ” she said of Jacobs and his allies. “Now, we have a lot of moderate Muslim voices, and they are saying that these are the most dangerous people because they are involved in civic society.”

But Webb, in an apparent effort to project both transparency and strength, soon found himself drawn into a back-and-forth on Twitter with Jacobs and the reporter who wrote the USA Today piece — an unusual situation for a major spiritual leader but one that Webb says reflects his populist impulses.

“@DrCharlesJacobs is one of the greatest islamophobes in America,” Webb tweeted. “No one should take anything he has to say seriously.”

He had a different response, however, when Jacobs charged that the imam had made homophobic remarks, pointing to a 2007 post on Webb’s virtual mosque site in which the imam called homosexuality an “evil inclination” and told a gay would-be convert to Islam to seek treatment for his “problems.” Jacobs also circulated a video, drawn from material from the past few years, that showed Webb belittling men who wore skinny jeans, and encouraging his congregation to speak out against gay marriage.

Webb tweeted that he had made “mistakes,” and, in an interview last week, said he had rethought the gay marriage issue. Even if Islam regards homosexuality as a sin, Webb said the constitution guarantees the rights of everyone to get married.

Webb said he is reluctant “to start arguing about other people’s liberties,” given his concerns about recent talk in Congress about surveillance of mosques and other potential infringements on Muslims’ rights.

And yet the period after the bombings presented opportunities to burnish relationships with Christians and Jews that Webb had begun developing long beforehand.

Ministers and rabbis attended Friday prayers at the Roxbury mosque; in one remarkable service, two rabbis from Boston’s largest synagogue addressed Webb’s congregation directly.

And Webb surprised Jewish leaders by attending — and live tweeting — an event at Andover Newton Theological School about a new book on Jewish megatrends, and tweeting about a conversation with Jonathan Sarna, a professor of American Jewish history at Brandeis, on parallels between challenges Muslims face today and those that confronted Jews a century ago.

Jeremy Burton, executive director of the Jewish Community Relations Council, said his group still has significant questions about the organization that manages the Roxbury mosque, the Muslim American Society. There have been concerns about whether the society maintains a relationship with the Muslim Brotherhood, an Islamist organization that has helped topple dictatorships in the Arab world but that also advocates Israel’s destruction.

A national spokesman for the society said it is an independent organization but maintains friendly relationships with many groups and that some of its founders years ago may have had ties to the Muslim Brotherhood. Leaders of the Roxbury mosque insist it has nothing to do with any foreign groups.

But dialogue continues. Burton said he has engaged with Webb in interfaith conversations and has seen him talking “about the kind of mainstream Islamic American rooted community he is trying to build here.”

Said Webb: “We can live in the past and go nowhere or we can understand how things are now, and live for the future.”

Lisa Wangsness can be reached at lwangsness@globe.com