KANO, Nigeria — In an imam’s quiet office, two young men in long hooded robes, their faces hidden by checked scarves, calmly described their deadly war against the Nigerian state.

The office door was open. Children from the Koranic school adjoining the mosque streamed past, laughing and jostling. Worshipers from the evening prayer service, which the young men had just left, poured into the parking lot. If the police had been alerted in any way, the two young men would have been instantly arrested, or worse. But neither appeared nervous about possible betrayal.

“It is not the people of Nigeria, it is only the army and the police who are against us,” said one of the men, explaining their membership in Boko Haram, the militant group that has claimed responsibility for killing hundreds in its battle against the Nigerian government. “Millions of people in Kano State are supporting us.”

His bravado notwithstanding, the violent Islamist army operating out of these dusty alleyways, ready to lash out and quickly fade back, is deeply enmeshed in the fabric of life in this sprawling metropolis, succored by an uneasy mix of fear and sympathy among the millions of impoverished people here.

The group’s lethality is undeniable. Boko Haram unleashed a hail of bullets and homemade bombs here last month to deadly effect: as many as 300 were killed in a few hours in the group’s deadliest and most organized assault yet after two years of attacks across northern Nigeria. It was an unprecedented wave of coordinated suicide bombing, sustained gunfire and explosions, much of it directed against the police.

But while Western and local officials cite the militants’ growing links to terrorist organizations in the region — presenting the ties as a reason behind the group’s increasingly deadly tactics and a cause for global concern — Boko Haram is not the imported, “foreign” menace Nigerian authorities depict it to be.

Photo

A member of Boko Haram, an Islamist group that has staged deadly attacks in Kano, in northern Nigeria. “Millions of people in Kano State are supporting us,” he said. Credit
Samuel James for The New York Times

Since 2009, the group has killed well over 900 people, Human Rights Watch says. Yet on the streets of Kano, the government is more readily denounced than the militants. Anger at the pervasive squalor, not at the recent violence, dominates. Crowds quickly gather around to voice their heated discontent, not with Boko Haram, but with what they describe as a shared enemy: the Nigerian state, seen by the poor here as a purveyor of inequality.

“People are supporting them because the government is cheating them,” said Mohammed Ghali, the imam at the mosque where the two Boko Haram members pray. Imam Ghali is known as an intermediary between the militants and the authorities, and while open backing for the group can put almost anyone in the cross hairs of the Nigerian security services, there appears to be no shortage of Boko Haram supporters here.

“At any time I am ready to join them, to fight injustice in this country,” said Abdullahi Garba, a candy vendor who came into Imam Ghali’s office.

Of course, Boko Haram is feared and loathed by countless residents as well. Its brutal show of firepower here in Kano, a commercial center of about four million that for centuries has been a major entrepôt at the Sahara’s edge, has left many residents in shock. The attackers came on foot, by motorcycle and by car, throwing fertilizer bombs and pulling rifles from rice sacks, mowing down anybody who appeared to be in uniform. There were even decapitated bodies among the mounds of corpses the day after, said a witness, Nasir Adhama, who owns a textile factory with his family near one of the attack sites.

“When you saw this road, it was just shed with blood,” Mr. Adhama said. “Everywhere there were dead bodies. They passed through this place, just firing and shooting.”

One of the young men at the mosque said he had participated in the planning for the attack, asserting that the group had received no outside help.

But a United Nations report published in January cited regional officials as saying that “Boko Haram had established links with Al Qaeda in the Islamic Maghreb,” and that “some of its members from Nigeria and Chad had received training in Al Qaeda in the Islamic Maghreb camps in Mali during the summer of 2011.” Seven Boko Haram members passing through Niger were arrested with “names and contact details” of members of the Qaeda affiliate, the United Nations report said.

Photo

Sudaifu Muhammadu says his father was killed near his home in a Kano suburb by gunmen suspected to be members of Boko Haram. “They are all around,” he said.Credit
Samuel James for The New York Times

For now, Boko Haram’s targets remain largely local, despite its bombing of a United Nations headquarters in Abuja, the capital, last summer. The Nigerian state is typically the enemy, and many analysts see the nation’s enduring poverty as one reason.

This month figures were released in Abuja indicating that poverty has increased since 2004, despite the nation’s oil wealth; in the north, Boko Haram’s stronghold, about 75 percent of the population is considered poor. Overall, 60 percent live on less than $1 a day. Every citizen appears aware of the glaring contrast between his or her own life and those of the elite.

“Injustice, and misgovernance by officials,” he said, adding, “It’s possible, as long as injustice persists, it’s possible to have another flare-up.”

Down the street, squatting in his open-air stall where he sells cooked yams, Abdullahi Dantsabe had a similar point of view. Why had the attacks occurred? “Injustice,” he said. “The leaders are not concerned about the common man.”

One resident argued that Boko Haram made some effort to protect civilians. “They told us to move away,” said Mohammed Danami, a motorcycle taxi driver, describing a devastating police station attack on Jan. 25. “They said, ‘We are not here for you,’ ” he recalled.

But the fate of Alhaji Muhammadu suggests otherwise. He was fatally shot on Feb. 9 as he walked along a sandy alley to his cinder-block home. His son said that his father had alerted the police to a booby-trapped car in the neighborhood, several days before the shooting. Boko Haram found out. Two masked men on a motorcycle shouted: “Just try that again. Now you are dead,” recalled the son, Sudaifu Muhammadu, a 27-year-old student at Bayero University, shuddering.

Photo

Kano, in the north of Nigeria, is a Boko Haram stronghold.Credit
The New York Times

“They are all around,” Mr. Muhammadu said.

Last July the Nigerian news media reported on a letter of warning from the group to Kano’s leaders, including the emir, the traditional ruler of this ancient aristocratic city: “All those arrested should be released immediately, otherwise, I swear with Almighty Allah, we may be forced to deploy our men to Kano,” the letter said.

Six months later, on Jan. 20, the group struck. The planning had gone on under the noses of the authorities. “What happened in Kano was something which the security agencies had foreseen,” said Dr. Bashir Aliyu, a prominent imam in Kano.

There were up to five suicide bombers that day, at least 20 explosions, assaults on what were thought to be well-guarded state and regional police headquarters, on the State Security Service, an immigration office and the residence of a high police official. Gunmen entered a police barracks and opened fire, killing dozens.

Kano officials have said little since the attacks, and the precise sequence of events that day remains a mystery. The police commissioner here declined requests for an interview, and the state’s information commissioner did not respond to a message or phone calls.

An elderly aristocrat with connections to the royal palace here, Yusuf Maitama Sule — Nigeria’s former United Nations ambassador, he was one of those to whom Boko Haram’s letter was addressed, according to the Nigerian media — said in an interview at his home here: “We are making some efforts quietly. I don’t think it is proper for me to speak out.”

Mr. Sule acknowledged, however, that the country faced deep social and economic challenges.

“Because of this oil habit, we are sending our girlfriends to do their hair in Paris,” he said.

For some analysts, the challenge posed by Boko Haram is a serious one for the Nigerian government.

“They’ve built cells in Kano,” said Paul Lubeck, a northern Nigeria expert at the University of California, Santa Cruz. “They have much deeper networks in Kano than anybody ever assumed. My position is, this is a remarkably successful insurrection, more than anybody ever could have thought.”

In the imam’s office, the two young men spoke calmly and confidently of ultimate triumph. “God has already positioned us to follow his rule,” said one of the men, 25. “At any time, we can gain victory. Because God will give it to us.”

Musa Ibrahim contributed reporting.

A version of this article appears in print on February 26, 2012, on page A6 of the New York edition with the headline: In Nigeria, a Deadly Group’s Rage Has Local Roots. Order Reprints|Today's Paper|Subscribe