Five other Pakistani men, some of whom were under 18 at the time of their crimes, were jailed for between three and 12 years on terror conspiracy charges for supporting Mehmood.
Due to his age, the trial was held in the Paris Juvenile Court.
The court heard that Mahmoud planned his attack after Charlie Hebdo republished cartoons of his prophet in September 2020 to mark the start of the trial against some of those responsible for the 2015 massacre.
The court was told that Mahmood was influenced by radical Pakistani preacher Khadim Hussain Rizvi who urged him to “avenge the Prophet”.
Armed with a meat cleaver, he stormed the former offices of Hebdo in the French capital’s 11th arrondissement, and attacked and seriously injured two employees of the Premier League news agency, which has offices nearby.
Eyewitnesses described at the time how they saw their comrades “covered in blood, being chased by a man”.
His victims, a 32-year-old woman named “Helen” and a 37-year-old man, were present at the sentencing but did not comment on the outcome.
Neither has Mahmood’s apology request been accepted.
“It broke something inside me,” the 37-year-old said, as he told the court about his long recovery process.
Mahmoud arrived in France illegally in 2017, although he initially claimed to have arrived in 2019. He also lied about his age, claiming to be 18.
Mahmoud’s defense lawyer Alberick de Giardin said his client lives and works with Pakistanis and feels disconnected from France.
“He doesn’t speak French, he lives with Pakistanis, he works for Pakistanis,” Mr Garden added. “In his head he never left Pakistan.”