LONDON (Reuters) - A 20-year-old man appeared in court on Wednesday accused of plotting to kill British Prime Minister Theresa May by first detonating an explosive device to get into her Downing Street office.

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.

Prosecutor Mark Carroll told the court Rahman planned to detonate an improvised explosive device at the gates of Downing Street and gain access to May’s office in the ensuing chaos and kill her.

“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. The men will appear at London’s Old Bailey central criminal court on Dec. 20.

No. 10 Downing Street is the official residence of British prime ministers. It is heavily guarded and there is a gate at the end of the street preventing members of the public from getting close to the house.

Slideshow ( 4 images )

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

A Downing Street spokesman declined immediate comment on the case.