French prosecutors have opened a terrorism investigation into the fatal stabbing of a French police official inside her police station near the historic Rambouillet chateau outside Paris.

Police shot and killed the attacker at the scene, authorities said.

Anti-terrorism prosecutor Jean-Francois Ricard told reporters that his office took over the probe because the attacker had staked out the station, because of statements he made during the attack, and because he targeted a police official.

Mr Ricard did not provide details on the attacker’s identity or motive.

French media reports identified him as a 37-year-old French resident with no criminal record or record of radicalisation.

A French judicial official said the suspect was born in Tunisia and that witnesses heard him say “Allahu akbar”, Arabic for God is great, during the attack.

French Prime Minister Jean Castex rushed to the scene with other officials and pledged the government’s “determination to fight terrorism in all its forms”.

Islamic extremists and others have carried out multiple terror attacks in France in recent years, including several targeting police.

The police officer killed on Friday was a 49-year-old administrative employee who worked for the national police service, a national police spokesperson told the Associated Press.

The national anti-terrorism prosecutor’s office opened an investigation into murder of a person of public authority in relation with a terrorist group.

Police near the scene of a stabbing at a police station in Rambouillet, south-west of Paris
Police near the scene of the incident (Clement Lanot via AP)

“Police are symbols of the republic. They are France,” Valerie Pecresse, president of the Paris region, told reporters at the scene, adding that “the face of France” was targeted.

The attack took place south-west of Paris just inside the police station in a quiet residential area of the town of Rambouillet, about 750 metres from a former royal estate that is sometimes used for international peace negotiations.

Police cordons ringed the area after the stabbing.

The attack comes as President Emmanuel Macron’s government is toughening its security policies amid voter concerns about crime and complaints from police that they face increasing danger.

The shift comes as France prepares for regional elections in June in which security is a big issue, and for a presidential election next year in which Mr Macron’s main challenger could be far-right leader Marine Le Pen, if he seeks a second term.