Grant Gallagher caused a disturbance outside the Mosque in Livingston, West Lothian.
He was heard shouting: “The soldier was innocent. He didn’t deserve to die – you terrorists killed him.”
He angrily grabbed the gate with both hands and shook it, screaming racist abuse.
Livingston Sheriff Court heard that an Asian man who witnessed the bizarre behaviour stopped his car and wound down the window.
A woman having a cigarette in her garden nearby also heard Gallagher’s 2am rant. They were so concerned that police were summoned.
Gallagher was detained and arrested some time later. He made no reply to caution and charge.
Gallagher, 55, of Lime Grove, Livingston, pled guilty to behaving in a threatening and abusive manner on May 26 last year.
He admitted shouting and swearing and making racist remarks during the incident, classed as a racially aggravated offence.
He originally appeared on petition charged with a solemn offence of brandishing a knife outside the Mosque and challenging people to fight.
But after the allegation was reduced to summary level the Crown accepted he was not guilty of those offences.
At an earlier hearing, Neil Robertson, defending, said the death of drummer Rigby had had a “profound effect” on Gallagher.
Although his client had been drinking with friends that day he had not spoken to them about the murder.
Mr Robertson said: “He did this spontaneously. There was no link between this and his activity earlier that day.
“He can’t really explain why he did what he did.”+