A man was carrying a large kitchen knife after an armed gang burst into his friend's Mansfield home and chased him into a shed, a court has heard.
Police were called after three men were seen chasing Davices Anderson and his friend, on the Bellamy Road estate, at around 12pm on May 24, said prosecutor Lee Shepherd.
Anderson was found hiding in a shed, after ditching the knife in bushes, and he told police: "I don't do knives but what was I supposed to do? They burst in with knives.
"I didn't wave it about or stick anyone. I just needed to get away."
Mr Shepherd said: "While he's not brandished it or used it to threaten anyone, and it is accepted there were people with knives chasing him, he did take the decision to carry the knife.
"There was a risk of serious disorder."
The court heard Anderson is subject to a community order, imposed in February 2019, for two counts of assaulting police officers.
Emma Cornell, mitigating, said Anderson had spotted the trio of men while visiting a friend and saw "they weren't happy with him, but didn't know why."
"They kicked the door in and burst in with knives and weapons," she said. "He was worried, he picked up a knife from the kitchen and ran out of the back door.
"There wasn't a reasoned thought-process into taking a knife into a public place.
"It was a split second decision. He didn't threaten anyone or brandish it."
She said Anderson initially denied the charge because he had just discovered his partner was pregnant.
Probation officer Lucy Harrison said part of Anderson's issues are drink-related and he suffers from a variety of mental health issues.
She recommended 10 rehabilitation days and an alcohol treatment programme for six months.
Anderson, 18, of Fairisle Court, Nottingham, admitted the offence after initially denying it, when he appeared at Mansfield Magistrates Court, on Thursday.
Magistrates said the offence was so serious and required greater punishment then they could mete out, so bailed him to Nottingham Crown Court for sentencing, on August 22, on condition he doesn't enter the Bellamy Road estate.
For more of the latest cases from Mansfield Magistrates Court click here.