Police arrested Stephane Poussier in his home in Normandy on March 25 after he posted a tweet celebrating the death of Lieutenant-Colonel Arnaud Beltrame.
"Whenever a policeman is shot… I think of my friend Remi Fraisse," Poussier wrote on Twitter, referring to a French botanist and environmental activist who was killed in a flashbang grenade explosion by French police during a series of violent clashes with protesters who opposed construction of the controversial Sivens Dam in 2014.
"And this time it was a colonel, great! Additionally, it means one less Macron voter," he added.
Last week, Beltrame, a 44-year-old gendarme, took the place of a female hostage during a supermarket seige by 25-year-old jihadist Radouane Lakdim, a French citizen of Moroccan descent. Beltrame was shot and stabbed to death.
Poussier's tweets received severe backlash and his Twitter account was promptly disabled.
"Stephane Poussier is in custody since 11:30 this morning for justifying acts of terrorism after comments published yesterday on his Twitter account," said local prosecutor David Pamart to AFP on Sunday. Poussier may be looking at seven years in prison and a $124,000 fine for his remarks.
Lakdim opened fire in a busy supermarket last week, pledging allegiance to Daesh and announcing his readiness to die for Syria and his "brothers." Four people were killed and 16 others were injured during the shooting spree before Lakdim was shot to death by police.
French President Emmanuel Macron has paid tribute to Beltrame, saying that he "fell as a hero" after exhibiting "exceptional courage and selflessness." Following the attack, Macron also stated that the officer deserved "the respect and admiration of the whole nation.
"He gave his life for strangers. He must have known that he didn't really have a chance. If that doesn't make him a hero, I don't know what would," Beltrame's brother Cedric told a French radio station on Saturday.
"Even though we were surprised and shocked when we heard what happened we were not surprised in the sense that that's the thing he would do without hesitation," Beltrame's cousin, Florence Nicolic, told BBC recently.
Last year, Poussier ran as a candidate for the La France Insoumise (France Unbowed) party of Jean-Luc Melenchon, a French left-wing politician who has served as member of the National Assembly of France.
Poussier's comments were also condemned by Melenchon's party last week, who also said that they would file a complaint against him Monday for justifying terrorism.