A gunman has shot dead three police officers who were called to a domestic violence incident in central France.
The suspect, 48, said to be known to authorities on child custody issues, was later found dead, officials said.
A woman had fled to the roof of a house in a remote village near Saint-Just in the early hours of Wednesday.
The gunman killed one officer and wounded another. He then set fire to the house and killed two more officers who arrived. The woman was rescued.
President Emmanuel Macron said the nation shared the grief of the families of the police officers.
Elite tactical police officers were at the scene on Wednesday in the village in the Puy-de-Dôme department, in France's Massif Central mountain region.
As the sequence of events became clear, prosecutor Eric Maillaud described the scene as a "real war zone" as he described a man who had been in conflict with his wife and had an arsenal of weapons. "What's certain is that he was totally battle-hardened in handling weapons," he told reporters.
The mayor of Saint-Just, François Chautard, said initially that the house had burned down but it took police time to confirm that the suspect was dead, and the prosecutor said an initial examination of his body suggested he had taken his own life.
Police told French media that he had been found dead in his car nearby. He was named locally as Frédéric Limol and described as a shooting enthusiast with a disturbing profile.
Interior Minister Gérald Darmanin visited the scene and named the first officer who died as Brig Arno Mavel, 21, and the two who died in the second incident as Lt Cyrille Morel, 45, and Adjutant Rémi Dupuis, 37.
The incident began late on Tuesday when the suspect's new partner raised the alarm with a friend shortly before 21:00 (20:00 GMT). She was bleeding and had fled to the roof of the building. Soon afterwards a gendarme patrol arrived, realised the man was dangerous and called for help.
The first shots were fired at around 22:30. The youngest of the three gendarmes was killed but a colleague was saved by his bulletproof vest.
The man then set fire to his home and shot dead the two other gendarmes. It later emerged he was wearing a bulletproof vest and had a gun equipped for night-vision. The gunman's partner was led to safety.
The man eventually fled in his car but crashed into a tree and was found with a Glock pistol in his hand.
Mr Darmanin expressed his profound sadness at the gendarmes' deaths and extended his condolences to their family, friends and colleagues. He said the deaths showed once more the risks that police officers were exposed to in their daily duties.
In his tweet, Mr Macron said the security forces put their lives at risk to protect the public and were "our heroes":
Ils intervenaient pour secourir une femme victime de violences conjugales dans le Puy-de-Dôme, trois gendarmes ont été tués, un quatrième blessé. La Nation s'associe à la douleur des familles. Pour nous protéger, nos forces agissent au péril de leur vie. Ce sont nos héros.— Emmanuel Macron (@EmmanuelMacron) December 23, 2020
In another tweet, Prime Minister Jean Castex said the tragedy touched the whole country. He said he shared the grief of the officers' relatives and sent his unwavering support:
Trois de nos gendarmes ont été tués cette nuit, alors qu'ils étaient engagés pour protéger et sauver.— Jean Castex (@JeanCASTEX) December 23, 2020
Ce drame nous touche tous et endeuille le pays tout entier.
Je partage la douleur de leurs proches et de leurs frères d'armes et les assure de mon indéfectible soutien.
The wounded officer was shot in the leg and his life is not in danger.
Gun attacks on police in non-terror-related incidents are relatively rare in France.
Two women police officers were shot dead during a dispute with a burglary suspect in the village of Collobrières, near Toulon, in 2012.