The man, who was on a terrorist watch-list according to the interior ministry, had been on the run after the attack in La Chapelle-sur-Erdre near the western city of Nantes.
A total of 250 officers were trying to find him, and two gendarmes were wounded in the exchange of fire that resulted in his arrest, authorities said.
No motive for the stabbing has emerged, but the attacker was “a known radical and suffering from a very serious psychiatric illness”, one source involved in the investigation said.
After stabbing the officer at a police station, inflicting life-threatening injuries, the suspect stole her service weapon and fled on foot.
(article continues below)
See also on The Local:
He then broke into the flat of a young woman, holding her there, and it was from there he fired on the gendarmes, prosecutor Pierre Sennes said.
The police officer he had stabbed was taken to hospital and later declared to be out of danger.
Prosecutors have opened an investigation into the attempted murder of the police officer and the gendarmes, and for the sequestration of the young woman.
“My first thoughts go to the police officer who was seriously wounded,” Prime Minister Jean Castex wrote on Twitter.
“She has all my support and… the support of the entire government.”
Interior Minister Gerald Darmanin, visited the scene in the afternoon.
“This French-born French national, around 40 years old and known to police services, was released from prison in 2016 where he was pointed out because of a strict practice of Islam and radicalisation”, he said.
That had led to his inclusion on a watch-list of potential terrorist sympathisers, he added.
Arrested in 2013 for aggravated theft, on his release he was ordered to follow treatment for schizophrenia.
Darmanin said the suspect had opened fire on the officers who shot back. He had died shortly after the shootout.
An AFP photo reporter at the scene said he heard around a dozen rounds discharged in two rapid bursts during the standoff, in a residential area.
Special police forces carrying shields and wearing helmets used rubbish bins and bushes for cover as they opened fire.
One witness told AFP he saw a civilian on the ground surrounded by police after the shootout.
Pupils in the area’s primary and middle schools were kept indoors while police tracked the suspect, a city official told AFP.
“We drew the curtains and told the children to lie on the ground. They’ve been there for two hours,” one local teacher told AFP by text message during the manhunt.
The suspect’s former lawyer, Vincent de la Morandiere, told AFP that his client’s psychological state had “deteriorated gradually during his various spells in prison”.
One neighbour described him as “very discreet and polite” while another said “he told me he had psychological problems. He lived alone and didn’t have any visitors. He told me he had a child”.
La Chapelle-sur-Erdre is a town of 20,000 inhabitants just north of Nantes near the Atlantic coast.
The attack came the same day Justice Minister Eric Dupond-Moretti called on French judges to show “firmness” when dealing with people found guilty of attacks on police forces.
Spate of attacks
French police officers have demanded better protection and harsher punishments for attacks against them after a spate of assaults in recent months.
Earlier this month, officer Eric Masson was shot dead while investigating activity at a known drug-dealing site in the southern city of Avignon.
Masson’s death came after the April 23 killing of Stephanie Monferme, a police employee who was stabbed in the town of Rambouillet outside Paris in the latest jihadist attack in France.
There was no immediate indication that the French authorities intended to open a terror probe into Friday’s attack.
But several attacks over the last year have reignited concerns about the spread of radical Islam inside France and immigration.
In September, a Pakistani man wounded two people with a meat cleaver outside the former offices of satirical magazine Charlie Hebdo which had printed cartoons of the Prophet Mohammed.
On October 16, a young Chechen refugee beheaded teacher Samuel Paty who had showed some of the caricatures to his pupils.
And on October 29, three people were killed when a recently arrived Tunisian went on a stabbing spree in a church in the Mediterranean city of Nice.
In the most severe recent attack against French police, three officers and one police employee were stabbed to death in October 2019 by a IT specialist colleague who was himself then shot dead. He was later found to have shown an interest in radical Islam.
In France’s deadliest peacetime atrocity, 130 people were killed and 350 were wounded when Islamist suicide bombers and gunmen attacked the Stade de France stadium, bars and restaurants in central Paris and the Bataclan concert hall in November 2015.