A racist firebombed an Asian-owned takeaway shop in Rosyth and then bragged about it online.
Charles Johnston wore a mask and waved a machete as he ranted online about Muslims a fortnight later and claimed he had burned down a kebab shop.
However, his identity was revealed after he blurted out his home address.
Johnston was also wearing the same hoodie as when he tried to torch the takeaway in Rosyth, an incident captured on CCTV.
He believed money being taken for kebabs was going towards terrorism.
Johnston, 20, of Tovey Road, Rosyth, admitted the offences in March but evaded justice until his arrest in October and has now finally been sentenced at Dunfermline Sheriff Court. He was jailed for four years.
Depute fiscal Alex Kirk previously told the court Johnston had gone on his bike to the takeaway after midnight, when it was closed and shuttered.
He was carrying a bottle full of petrol and had just bought a lighter from a local garage.
He said the CCTV showed him set fire to the bottle and throw it at the takeaway, filming his actions on his mobile phone.
He said: “The accused is observed holding out his mobile phone as though recording this. He then runs away, retrieving his bike and cycling away.”
Around a fortnight later, Johnston was bragging on the internet.
He said he set the kebab shop on fire and spat on a mosque.
He ranted: “I’m gonna take ISIS in my stride. I set a kebab shop on fire because halal food contributes a 2% tax. Every kebab bought contributes to terrorist organisations.”
Defence solicitor Elaine Buist said in March: “He says he doesn’t have anything against individual Muslims.”
Sheriff Charles MacNair responded: “That is what is said by just about every racist. He clearly is a racist.”
However, when he was brought back to court for sentencing, Ms Buist said, “He now admits that at the time he was holding extreme views.”
Johnston admitted that on May 18 last year at Shalimar Kebab, Queensferry Road, he wilfully set fire to the premises by setting light to a bottle containing petrol and throwing it at the premises.
The fire took effect, damaging the shutters, and the offence was aggravated by religious prejudice.
He also admitted that on June 2 last year, at his home, he uploaded a live video to an online broadcasting service, Periscope, in which he repeatedly uttered racist, offensive and abusive remarks, all whilst holding a machete with his face masked.
He further admitted that on the same day, at Sherbrooke Road, he was in possession of a lock-knife.