LONDON (Reuters) - A British man was found guilty on Wednesday of a plot to kill Prime Minister Theresa May by first detonating an explosive device to get into her Downing Street office and then using a knife or a gun to attack her.

Britain's Prime Minister, Theresa May, appears on the BBC's Andrew Marr Show in London, Britain July 15, 2018. Jeff Overs/BBC Handout via REUTERS

Naa’imur Rahman, 20, of north London, was convicted at the Old Bailey court of preparing to commit acts of terrorism.

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, according to police.

No. 10 Downing Street is the official residence and office of British prime ministers. It is heavily guarded and there is a gate at the end of the street where members of the public and tourists gather to get a glimpse of the house.

“We are talking about an individual that would have killed, injured and maimed a number of people including police officers and members of the public,” said Dean Haydon, head of the Metropolitan Police’s Counter Terrorism Command.

Britain suffered four deadly attacks last year and the head of the domestic spy agency MI5 said in May that a further 12 Islamist plots had been foiled since the first of these in March 2017.

The Downing Street plot was foiled when Rahman believed he was corresponding online with members of the Islamic State (IS) militant group while planning the alleged attack but was in fact talking to members of undercover officers from the U.S. Federal Bureau of Investigation and Britain’s MI5 Security Service.

Rahman was arrested last November shortly after meeting with undercover officers posing as IS members and collecting two dummy explosive devices.

Haydon said Rahman had been in contact with an uncle who had traveled to Syria and joined IS and who had encouraged his nephew to carry out attacks in Britain.

Rahman had been planning to carry out the attack for two years but his resolve was hardened when he heard that his uncle had been killed in a drone attack last summer, Haydon added.

Rahman was described by police as a drifter, who lived on friends’ sofas, and attempts to involve him in the government’s counter-extremism program had failed.