Dylan Curran was also found to have two bags of the killer drug ecstasy on him when he was collared by officers at Bonnyrigg primary school in Midlothian last year.
Curran, 19, was among a group of youths who had congregated at the school and officers were called in after neighbours raised concerns of possible drug taking.
The gang scattered when police arrived at the school but Curran was soon caught nearby in a residential street.
And during the subsequent search officers discovered the offensive weapon along with the Class A drug haul.
The teen appeared at Edinburgh Sheriff Court on Tuesday where he pleaded guilty to possessing the knuckleduster and the bags of ecstasy.
Prosecutor Nicole Lavelle told the court the gang of teens were spotted within Bonnyrigg primary school at around 8pm on October 15 last year.
Ms Lavelle said the gang ran off when approached by officers and Curran was nabbed in a street close by.
The fiscal added: “Due to his demeanour he was detained and while under caution he admitted having two bags of ecstasy on him.
“The accused was searched and in trousers within his bag officers found a knuckleduster and the accused was subsequently arrested.”
The fiscal said the 2.09 grammes of the drug was worth around £20.
Iain Tweedie, defending, said unemployed Curran “cooperated fully with police” and he was carrying the weapon due to being “threatened by other youths”.
Sheriff Peter McCormack said: “As this is your first offence I will issue a fine to cover both charges.
Curran, from Bonnyrigg, was ordered to pay a fine of £270.
Curran admitted to possessing a knuckleduster and possession of ecstasy at Cockpen Road, Bonnyrigg, Midlothian, on October 15 last year.
Sign up to our newsletter: enter your email in the box at the top of this article to get daily updates straight to your inbox.