A football fan has apologised to a judge for running on to the pitch and taking a free kick during a Premier League match.

Jordan Dunn, 22, from Dover in Kent, became an internet sensation after he kicked the ball towards the goal West Ham United were defending at Upton Park against Tottenham Hotspur last month.

His shot was saved by West Ham's Spanish goalkeeper Adrián San Miguel del Castillo while Dunn was chased by a steward amid cheers from the crowd.

On Monday he apologised for a "moment of madness" on 16 August, pleading guilty at Thames magistrates court in east London to a charge under section 4 of the Football Offences Act 1991, which states that it is an offence to go on to the playing area without lawful authority or excuse. He is facing a ban from matches and a fine.

Ben Edwards, prosecuting, said: "At around 4pm in the afternoon the defendant was seen to jump the barrier separating football fans from the pitch and run along the pitch towards the goal. He was then seen to kick the football being placed on the ground for a free kick."

Dunn told police after he was arrested that he had been a West Ham fan since he was a little boy and it had always been one of his dreams to "run on the pitch and kick the ball", the court heard.

Edwards added: "Now he could say he had done it. He also said now he had done what he wanted to do he is not going to do it again."

Asked what was going through his mind by district judge Gareth Branston, Dunn said: "Nothing really – it was just a moment of madness. It was a spur of the moment thing. I just went."

The judge said he had seen footage of the incident on YouTube and asked: "Were you intending to take the free kick?" Dunn replied: "No. All I was going to do was run and as I was running I just saw the ball there so I thought I would just kick it."

He said he was sorry for committing the offence and admitted he had drunk about six beers before the match but denied being a hooligan, thug or yob.

Dunn, a hotel receptionist, said he has a 10-month-old boy. Referring to the prospect of a banning order, he said he expected to be barred for a period, but added: "I was a bit concerned that when my little boy grows up I want to take him to watch the football."

The judge asked if his mother had "expressed disapproval". Dunn said: "At first she was concerned because she didn't know the consequences, but when she saw the YouTube video she saw the funny side but she has had a go at me, as a mother would."

The pitch invasion provoked amusement on social media, with one fan saying the effort was better than Spurs star Christian Eriksen's free kick once play had resumed.

Dunn will be sentenced later.