Police shot and killed the attacker at the scene on Friday, authorities said.
Anti-terrorism prosecutor Jean-Francois Ricard told reporters his office took over the probe because the attacker had staked out the station ahead of time, 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 witnesses heard him say “Allahu akbar,” Arabic for “God is great,” during the attack.
The judicial official was not authorised to be publicly named speaking about an ongoing investigation.
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 official 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 woman had left the station briefly to extend the time on her parking space and was attacked in the entry passage as she returned, said Valerie Pecresse, president of the Paris region.
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 are symbols of the republic. They are France,” Ms Pecresse told reporters at the scene, adding: “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.
Security cordons ringed the area after the stabbing.
Masked police employees clustered outside the station, while uniformed officers in bulletproof vests stood watch around the neighbourhood.
The prime minister noted that the surrounding Yvelines region has seen two particularly brutal Islamic extremist attacks on public servants in recent years: last year’s beheading of a teacher by a Chechen extremist, and the 2016 fatal stabbing of a police couple in their home by a Frenchman who claimed allegiance to the Islamic State group.
Friday’s attack came 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 Macron’s main challenger could be far-right leader Marine Le Pen, if he seeks a second term.