A man accused of trying to assassinate British Prime Minister Theresa May in a failed terrorist plot was sentenced to at least 30 years in prison.

Naa’imur Zakariyah Rahman, 21, from north London, was convicted last month of planning to bomb the entry gates to the prime minister’s residence at 10 Downing Street and then attack May with a knife or gun when she emerged.

He was arrested in November after collecting a backpack he believed was stuffed with explosives. He thought he was getting the explosives from ISIS adherents, according to officials, but had actually been talking to undercover police.

“I want to do a suicide bomb on parliament,” Rahman reportedly told the undercover cop, Sky News reported. “I want to attempt to kill Theresa May.”

SUSAN RICE MOCKS UK PRIME MINISTER FOR AWKWARD DANCE MOVES: 'SOMEBODY HELP HER, PLEASE'

“[God willing] will be very big if I’m successful. I can’t get [martyrdom] if I get caught,” he reportedly told the cop.

Police said they began investigating Rahman when he was arrested on suspicion of sending indecent images to underage girls in August last year. They said there was concern about potentially extremist views after examining his cellphone, Sky News reported.

Rahman’s uncle – who had travelled to Syria and was killed in a drone attack last June – reportedly was the one who encouraged him to take action against May.

Judge Charles Haddon-Cave sentenced Rahman Friday to life with no chance of parole for 30 years. The judge said Rahman was "a very dangerous individual" and it was hard to predict whether he would ever be de-radicalized.

Rahman's alleged accomplice, Mohammed Aqib Imran, who is accused of trying to join the Islamic State group but was not charged in the assassination plot, has pleaded not guilty.

The Associated Press contributed to this report.