Hearts defender Lee Wallace has admitted having a loaded airgun in the back of a friend's car while driving around an Edinburgh car park.
Lee Wallace played in the Scotland under-19s team
Police stopped the car at about 0140 BST on Friday 4 August because it was moving too slowly.
Wallace, 19, was originally charged with having a gun but pleaded guilty to the reduced charge of possessing an air weapon in Sighthill Green car park.
Sentence was deferred at Edinburgh Sheriff Court until 28 September.
As soon as the police asked Wallace, who has never been in trouble with police before, if he had anything to declare he pulled the loaded gun from his jacket pocket.
The defender, who played for Scotland in the recent Under-19 European Championship campaign, wore a dark suit and sat calmly in the dock.
He admitted he had bought the weapon earlier that day and had been shooting bottles and cans in the area.
The airgun was fully loaded and the defender also had 10 pellets with him.
Defence agent Iain McSporran said the teenager, who has just signed a five-year deal with Hearts, had not realised the weapon was illegal and co-operated fully with the police.
"He did not seek to conceal the weapon to the police. After contacting me, he immediately asked to plead guilty as soon as I advised him it was an offence," Mr McSporran said.
"This was a foolish action rather than something worse. It was a clear error of judgement," he added.
Sheriff Kenneth Maciver said: "For a young man in your situation this was at best an act of extreme stupidity.
"It clearly gave cause for concern. You were in the company of young men in a vehicle in the early hours of the morning in possession of a loaded air weapon.
"The court must recognise the real potential for danger and I want to be clear there is nothing sinister in this set of circumstances."
Wallace, who lives with his parents in Edinburgh, was accompanied in court by his agent Gary MacKay.
His employers Hearts have backed the youngster.
A spokeswoman said the club was satisfied there was no malice in his behaviour and they were confident of his future.
She added: "Lee is now solely focussed on furthering his professional footballing career with Hearts."