Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

LONDON — A 20-year-old man appeared in court on Wednesday accused of plotting to kill British Prime Minister Theresa May.

Naa'imur Rahman, of north London, has been charged with preparing to commit acts of terrorism. He was remanded in custody after a brief appearance at Westminster Magistrates Court.

British Prime Minister Theresa May Christopher Furlong / Getty Images

Prosecutor Mark Carroll told the court Rahman planned to detonate an improvised explosive device at the gates of 10 Downing Street, the official residence of British prime ministers, and gain access to May's office in the ensuing chaos and kill her.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

"The secondary attack was to be carried out with a suicide vest, pepper spray and a knife," he told the court.

Rahman was carrying two inert explosive devices when he was arrested last week, the court heard.

"His purpose was to attack, kill and cause explosions," Carroll said.

Rahman appeared with a co-defendant, 21-year-old Mohammed Imran, from Birmingham, who is also charged with preparing to commit acts of terrorism. Carroll said Imran was accused of trying to join the Islamic State militant group in Libya.

Rahman and Imran gave no indication as to their plea so a not guilty plea was entered on their behalf. There was no application for bail.

In 1991, Irish Republican Army militants launched a mortar bomb attack on 10 Downing Street. John Major, the prime minister at the time, was inside but not hurt.