The 25-year-old was arrested following the attack of Sir David Amess at a constituency surgery in Leigh-on-Sea in Essex on Friday.
In a statement, Nick Price, of the Crown Prosecution Service, said: “The CPS has authorised charges against Ali Harbi Ali for the murder of MP Sir David Amess on Friday 15 October 2021. We will submit to the court that this murder has a terrorist connection, namely that it had both religious and ideological motivations.
“He has also been charged with the preparation of terrorist acts. This follows a review of the evidence gathered by the Metropolitan Police in its investigation.
“The Crown Prosecution Service reminds all concerned that criminal proceedings against Mr Ali are active and that he has a right to a fair trial.”
Mr Ali is a British man of Somali heritage whose father is a former adviser to Somalia’s Prime Minister.