LONDON — A man who arrived at a British airport for a flight with a pipe bomb in his hand luggage was sentenced on Wednesday to 18 years in prison.

Manchester Airport security staff found the device inside Nadeem Muhammad’s bag on Jan. 30. It contained gunpowder and batteries inside a marker pen tube.

The 43-year-old denied wrongdoing, saying the bomb must have been planted by someone else. But prosecutors said he planned to detonate it during a Ryanair flight to Italy.

Earlier this month he was convicted by a jury at Manchester Crown Court of possessing explosives with intent to endanger life or property.

Sentencing Muhammad, judge Patrick Field criticized airport staff for making a “wholly erroneous and potentially dangerous” conclusion that the bomb wasn’t viable.

Muhammad wasn’t arrested when he was initially stopped, and was allowed to fly to Italy several days later. After he departed, a forensic expert examined the device and judged it to be “crude but potentially viable.”

Muhammad, who was born in Pakistan and has an Italian passport, was arrested when he returned to Britain.

The judge said he had heard no evidence about Muhammad’s motivation, and “cannot conclude this was an offence with a terrorist connection.”

But he said that had the bomb exploded aboard a plane, it “could have caused not inconsiderable injury and damage to those close to the explosion.”

Field said he hoped “that security at the airport and policing at the airport will be subject to a review at the highest level.”