Police arrested Stephane Poussier at his home in Dives-sur-Mer, northwest France, on Sunday after he sent two tweets welcoming the death of Lieutenant-Colonel Arnaud Beltrame.
“Whenever a policeman is shot… I think of my friend Remi Fraisse,” Poussier said on Twitter, referring to an environmental activist killed by a stun grenade fired by police during a 2014 protest over a dam.
“And this time it was a colonel, great! Additionally, it means one less Macron voter,” he added.
Beltrame was shot and stabbed to death after offering himself in exchange for a woman being used as a human shield by Radouane Lakdim who had already killed three other people in a rampage on Friday.
A national tribute is to be held for Beltrame, who President Emmanuel Macron said had “died a hero”.
Poussier's remarks provoked strong reactions and his Twitter account was disabled.
“Stephane Poussier is in custody since 11:30 this morning for justifying acts of terrorism after comments published yesterday on his Twitter account,” local prosecutor David Pamart confirmed to AFP late Sunday.
He could face up to seven years in prison and a fine of 100,000 euros ($124,000).
Poussier stood unsuccessfully in elections last year as a candidate for the La France Insoumise (France Unbowed) party of radical leftwinger Jean-Luc Melenchon.
His comments were condemned by the party and Melenchon, who said on Twitter that it would on Monday file a complaint against him for justifying terrorism.