A student has narrowly avoided a jail term for his part in a pitch invasion at the end of the Scottish Cup final.

Greg Binnie, of Ratho, Edinburgh, pleaded guilty to running at and making offensive gestures towards Rangers' goalkeeper Wes Foderingham after climbing over fencing at Hampden Park on May 21.

The sports coaching student appeared at Glasgow Sheriff Court on Thursday to face charges under the Offensive Behaviour at Football Act.

The 19-year-old admitted engaging in behaviour which was likely to incite trouble following the Hibs v Rangers game.

Binnie was ordered to carry out unpaid work and handed a two-month curfew.

Since the incident, Hibs have issued Binnie with an indefinite ban from watching the team playing or buying any tickets for home or away games.

The court heard Binnie climbed over fencing and entered the field of play immediately following the conclusion of the match between Rangers and Hibs, which the Edinburgh club won 3-2 with a last minute goal.

Binnie then ran at Foderingham and gestured in an offensive manner.

Sheriff Ian Miller told the teenager the maximum sentence was a year in prison and his actions "merited" a custodial sentence.

He said: "I see no public utility in sending you to prison, instead I see a much greater public benefit in giving you the chance to use your considerable gift and talent in a way, while giving others a chance to take advantage of this gift and talent."

He handed Binnie a community payback order with the condition he must carry out 240 hours of unpaid work in six months and a restriction of liberty order requiring him to stay in his home between 8pm and 6am.

The court heard that after the match police viewing CCTV identified Binnie and he was taken from his house on May 24 before appearing in court the following afternoon.

Procurator fiscal depute Stephen Ferguson said: "Immediately after the final whistle being blown, a number of football supporters made their way on to the pitch, including Mr Binnie.

"Mr Binnie ran towards the Rangers goalkeeper, Wesley Foderingham.

"Mr Foderingham was standing at the goalposts near to the east end of the stadium where the majority of Hibs fans were housed.

"As Mr Foderingham was approached by the accused, offensive gestures were used, using two hands to make a two-finger gesture."

The court heard Binnie had no previous convictions and testimonies on his behalf from college lecturers and others were given to the court for consideration.

Binnie, a former SFA intern, was working as a squash coach at George Watson's College in Edinburgh and has lost his job.

Defence counsel Lorenzo Alonzi described Binnie's actions as "boyhood stupidity".

He said it was "stupidity arising out of the sheer excitement of the situation".

The lawyer said: "Mr Binnie has already been punished significantly as a result of the direct consequence following his actions that day."

The court heard both he and his mother had received threats on social media and he was "genuinely remorseful".