Police shot dead the 18-year-old attacker, who was born in Russia, minutes after he murdered 47-year-old history teacher Samuel Paty in broad daylight in Conflans-Sainte-Honorine on Friday.
A photograph of the teacher's body, accompanied by a message claiming responsibility posted on Twitter, was discovered on the assailant's phone, found near his body. Ricard said the Twitter account belonged to the attacker.
The post was removed swiftly by Twitter, which said it had suspended the account because it violated the company's policy.
Ricard quoted the message as saying: "In the name of Allah the most gracious, the most merciful, ... to (President Emmanuel) Macron, leader of the infidels, I have executed one of your hell-hounds who dared to belittle (Prophet) Mohammad."
Earlier this month Paty had shown his pupils cartoons of the Prophet Mohammad in a class on freedom of expression, angering a number of Muslim parents. Muslims believe that any depiction of the Prophet is blasphemous.
The attacker, of Chechen origin, had been living in the town of Evreux northwest of Paris, and was not previously known to the intelligence services, Ricard told a news conference.
The killing shocked the country and carried echoes of an attack five years ago on the offices of satirical magazine Charlie Hebdo. Prime Minister Jean Castex said it bore the hallmarks of Islamist terrorism.
"I want to share with you my total indignation. Secularism, the backbone of the French Republic, was targeted in this vile act," Castex said.
Unions, anti-racism groups and Charlie Hebdo are organizing a gathering in central Paris on Sunday to commemorate the murdered teacher.
A national tribute will be organized for Wednesday, Macron's office said.
'BETWEEN HAMMER AND ANVIL'
Four close relatives of the attacker were detained soon after the attack. Five more were detained overnight, including the father of a pupil at Paty's school, College du Bois d'Aulne, and an acquaintance of the pupil's father known to the intelligence services, the anti-terrorism prosecutor said.
A tenth person was placed in custody in connection with the attack later on Saturday, BFM TV said, citing judicial sources.
In the days after the lesson on freedom of expression, the pupil's father recorded several videos in which he branded the teacher a thug and called for him to be fired. In one, he urged others to "join forces and say 'stop, don't touch our kids'."
The videos where shared on social media.
The half-sister of the pupil's father had joined Islamic State in Syria in 2014, the prosecutor said. It was not immediately clear if the teenage attacker knew either the pupil's father or the father's acquaintance.
Parents of pupils laid flowers at the school gate. Some said their children were distraught.
"(My daughter) is in pieces, terrorized by the violence of such an act. How will I explain to her the unthinkable?" one father wrote on Twitter.
In an outpouring of grief, the hashtag #JeSuisSamuel (I am Samuel) trended on social media, like the #JeSuisCharlie call for solidarity after the attack on Charlie Hebdo in 2015.
Before that attack, Charlie Hebdo had published caricatures of the Prophet Mohammed, unleashing divisions that still cast a pall over French society.
Muslim leaders condemned Friday's killing, which many public figures perceived as an attack on the essence of French statehood and its values of secularism, freedom of worship and freedom of expression.
Deadly attacks by Islamist militants or their sympathizers was devastating for France's Muslim community, Tareq Oubrou, the imam of a Bordeaux mosque, said.
"We are between hammer and anvil," he told France Inter radio. "It attacks the Republic, society, peace and the very essence of religion, which is about togetherness."