GUSAU, Nigeria — Tijani Idris heard the roar and rushed inside his home, peeking through the window to spot fighter jets crisscrossing the sky above his forest village.
They were Nigerian Air Force jets, scrambled to battle yet another major security threat in one of Africa’s most populous nations: groups of armed gangs that have made the northwestern corner of the country their haven.
This year alone in the state of Zamfara, hundreds have died in mass murders and more than 21,000 people have been forced from their homes. In total, officials say at least 2,000 people have died from violence in the area since 2011.
Earlier this month, the president responded with force, sending 1,000 troops and jets to fight the gangs.
“I saw the planes, I felt encouraged,” said Mr. Idris, a medical assistant who lives in Mashema Village in the northern edge of Zamfara State.
Nigeria is beleaguered by security threats. In the northeast, Islamist extremists from Boko Haram and its splinter groups are waging increasingly complex attacks on military forces and civilians. In the middle part of the country, more than 1,300 people have been killed in increasingly vicious land disputes between cattle herders and farmers. Farther to the south, violence spikes from time to time in the Biafra region, where separatists are pushing to secede. And in various pockets throughout the country, like a major highway between Kaduna and Abuja, kidnappings of prominent figures and regular Nigerians alike have become common.
The threats are becoming a major issue for President Muhammadu Buhari as he tries for a second term in February. Increasingly, critics, and even allies, complain about his failure to take control of the security situation.
After Mr. Buhari took office in 2015, he made advances in pursuing Boko Haram, but he has not delivered on his promise to defeat the group once and for all. Even as the war rages, he has repeatedly claimed victory, prompting outrage by some over exaggerated proclamations. Last year, dissatisfaction with the 75-year-old president grew while he was out of the country for several weeks receiving medical treatment in London for an undisclosed illness.
After almost a decade into the Boko Haram insurgency, security resources on the frontlines of the conflict are increasingly stretched. On Sunday, according to local reports, several soldiers brought an airport in Borno State, in northeastern Nigeria, to a halt, shooting into the air and threatening their superiors to protest working conditions. It is the third time this year that security forces have protested their plight stemming from the conflict.
Recently, security has deteriorated significantly. In July alone, a total of more than 400 people were killed by Boko Haram or gangs in Zamfara, or in the herder-farmer conflict, according to the International Crisis Group.
In recent weeks, Mr. Buhari’s All Progressives Congress party has been hit with a wave of defections. More than 50 lawmakers, state governors and party members have joined the opposition People’s Democratic Party, many of them worried that any alignment with the president could challenge their prospects in next year’s elections.
And bizarre events have left many in the nation concerned about the general state of democracy. Twice in recent weeks, security forces from the Department of State Services, the top spy agency, have appeared in black face masks outside the National Assembly. On Aug. 7, they blocked lawmakers from entering.
Later that day, Vice President Yemi Osinbajo fired the head of the agency. And on Tuesday, he announced that a notorious security agency, the Special Anti-Robbery Squad, would be shut down. The decision was widely welcomed; it followed several months of criticism that Mr. Buhari was again deaf to the concerns of Nigerians, after several protests against alleged abuses by the agency.
Analysts see Mr. Buhari’s dispatching of fighter jets to combat the gangs in Zamfara as a belated show of force for a president eager to appear like he has control over security.
“Everyday Nigerians read this in the papers, see it happening in their lives, it is a large cause of dissatisfaction,” said Nana Nwachukwu, a political activist who says even people who voted for Mr. Buhari are now questioning their support for him.
In Zamfara, the military is battling gangs that Nigerian officials refer to as “bandits.” These bandit groups and rival militias have for years looted and extorted residents and carried out mass killings from their secret forest hide-outs.
Anaruwa Bello, 65, who lives in the village of Kware, said the scale of the attacks this year has been unlike anything he has ever seen. The attackers are increasingly bold, not even bothering to cover their faces as they steal from villagers and go on shooting sprees. He said he has counted 26 people in his area who have died in recent attacks.
Mr. Bello gathered his 15 children and fled after dozens of militants on motorbikes invaded his village in July. He welcomed the new push from the military.
“If the army would have come before, these killings would not have been so severe,” he said. “This criminality did not just start now. It has been going on for many years, with nothing done.”
Locals in Zamfara, as in many conflict-ridden areas of the country, blame government neglect for allowing the violence to escalate. State government officials estimate that about 2,000 armed bandits are at work — equal to the number of police in the entire state.
In several small villages, bandit groups are virtually in charge, exploiting the absence of police or local administration.
Locals say their plight began in 2009 as groups of cattle rustlers operated in the area with impunity. The thieves eventually grew into organized, heavily armed criminal gangs, marauding across the cattle-rearing region. They hid in the forests, usurping locals who made their living mining gold and chopping trees for wood.
The police quickly were outmaneuvered, so an armed group of vigilantes called the Yan Sakai rose up. The state government even initially paid vigilante members a small stipend.
But the group abused its power, according to residents and officials. In 2016, the Yan Sakai was banned by the state government after reports of rapes and extrajudicial killing — and suspicions the vigilantes themselves had become involved in criminality.
That same year, officials signed a controversial peace accord with several other bandit groups including a powerful leader, Buharin Daji, widely seen as the ringleader of area violence.
The peace accord did not last, and after more cattle thefts, the nation’s spy agency tried to arrest Mr. Daji, but he eluded them and the agency instead arrested members of his family. Earlier this year Mr. Daji was killed, apparently after a dispute with another gang member.
Before his death, Mr. Daji pledged that his followers would make Zamfara “the worst place to live in Nigeria after Borno,” the beleaguered state where Boko Haram is particularly active, said Ibrahim Dosara, a spokesman for the state government.
Some residents describe the extent of control the groups have on the area as an occupation. The bandits announce their arrivals ahead of time in some villages and have imposed mafia-like taxes elsewhere.
The violence has also fueled ethnic divisions within the state between the Hausa and Fulani communities. Many gangs are thought to comprise mostly Fulani members, but Fulani have also been victimized. When they show up at displaced persons camps, Hausa victims have tried to push them away.
Lawal Mustapha, a university student in Zamfara, said he hoped the military intervention in Zamfara would lead to lasting changes. “We want them to restore Zamfara to how it was before all these killings, a peaceful state,” he said. “That will only happen if they improve security permanently, not just to send soldiers in who will then leave soon after.”