A man haunted by an encounter with three armed intruders ordered 3,200 diazepam pills from Pakistan.
Thomas Cross, 31, from Bracebridge Heath, became dependent of the Class C drug following his ordeal a number of years ago.
He decided to stockpile the drug earlier this year due to a reduced prescription, Lincoln Magistrates' Court heard.
But his international order was intercepted by customs.
His solicitor, Lloyd Edwards, said: "He was subjected to having three masked men break into his house.
"One was armed with a pistol, one with a knife and one with a baseball bat.
"The gun was placed in his mouth and he was pistol whipped.
"This had a dramatic effect on his mental health.
"He finds it difficult to deal with anything unexpected.
"One good effect of all of this is he's been forced to confront his dependency on diazepam.
"He's now undergoing counselling for what happened."
The court heard customs officers seized a parcel containing the pills which was addressed to a friend in Warwickshire.
A controlled delivery was made but the associate denied ordering the package.
The trail then led to Cross's address where Western Union documents were found confirming payment in Pakistan.
Marie Stace, prosecuting, said Cross suffers post traumatic stress disorder and can take up to 20 diazepam tablets on a bad day.
"He said he was dependent on the drug," she said.
"There was to be a reduction in the drug – his GP has confirmed this – he panicked and bought his own."
At an earlier hearing, Cross admitted importing 3,200 tablets of Diazepam with intent to evade a prohibition or restriction in Warwickshire on May 29 this year.
He also pleaded guilty to a further importing charge, relating to a quantity of the drug, in Lincoln on December 22, 2008.
Cross, of Grantham Road, was granted unconditional bail and will be sentenced at Lincoln Crown Court on a date to be confirmed.