The Moroccan national, who allegedly carried out radicalisation and proselytising activities on the Internet, faces charges of terrorism association.
It is the third time he has been arrested.
He also ended up in handcuffs in 2015 and in 2018, when he lived in Lanzo, near Turin, over terrorism charges and links with the Daesh.
He had obtained Italian citizenship but was stripped of this after being convicted.
After being released from prison in July 2023, a legal technicality prevented Elmahdi from being deported.
Investigators said his fundamentalist beliefs hardened during his time in jail and he became increasingly violent, both during his detention and after his release.
ANSA