A man who carried out fire attacks at a Sikh temple and a church because he wanted to make a “political statement” has been jailed for four years.

Paul Johnson, who was said to have issues with religion, used petrol to ignite the doors of Edinburgh’s Guru Nanak Sikh temple and Leith Methodist church this summer.

Johnson, 49, admitted two charges of wilful fire-raising aggravated by religious prejudice, on 28 August when he appeared at the high court in Edinburgh last month.

Paul Johnson appeared to have a grudge against religion, the judge said. Photograph: Police Scotland/PA

Returning to court for sentencing on Thursday, the judge Lord Boyd described Johnson’s actions as “reckless and wicked”.

He said Johnson appeared to have a “grudge” against religion or religious authority in general, rather than a prejudice against one particular group.

The court heard how during the attack on the Sikh temple, smoke entered the building and put the lives of those inside at risk.

The attack was only carried out when Johnson happened to come across the building.

The court heard that on the evening of 27 August, Johnson bought a container and fuel worth £3.51 from a local petrol station.

Shortly before 5am on 28 August, a man heading to the temple to pray spotted fire had taken hold on one side of the doors and immediately raised the alarm with a man sleeping inside in the family quarters.

The fire service was then alerted and 11 firefighters attended to bring the blaze under control.

A few hours later, the caretaker at Leith Methodist church noticed the smell of petrol and burning but continued to clean up the area around the front door as there were no signs of fire damage .

He later contacted police after hearing about the incident at the temple.

CCTV footage from the area around the church between 12.03am and 12.13am showed Johnson approaching the church door, with a flash of light then visible.

Footage from the temple from 12.38am to 1.07am revealed him approaching the door with a jerry can and lighting a piece of paper. He returned on two further occasions during that time to light more paper and throw it towards the door before running away.

Police arrested Johnson after spotting him in Leith in the early hours of 30 August. Asked about his involvement in the two fires, he immediately told officers: “I did it.”

Advocate depute Alan Cameron told the court previously: “The accused stated that his intention in buying the petrol was to start the fire at the Methodist church and that the fire-raising at the Sikh temple was not planned and was only carried out when he came across the building.

“The accused was asked as to his motivation for the fires and stated that he was looking to make a political statement, but would not provide further details.

Cameron added: “When asked whether this was religiously motivated he stated that he has no issue with any particular religion but his issues are with religion and God in general.”

Lord Boyd said at the sentencing hearing on Thursday: “What is clear is that you seem to have some sort of grudge against religion or religious authority and decided to take it out on two nearby religious buildings.

“You told police officers that you were confident that no one was in the building and that fire officers would not be at risk because of their training. You were of course wrong about people being in the building and your actions did put people at risk.

It is clear from what I can glean about these offences that they were motivated by a grudge against religion or religious authority in general rather than prejudice or bigotry against any one group. Indeed you appeared unaware of the religious denomination of the buildings themselves”, Boyd said.

Johnson, listed as a prisoner in Edinburgh, has a criminal record which includes two convictions for culpable and reckless conduct.

The court also heard that he had failed to properly engage with his defence counsel or the process of compiling a criminal justice social work report before sentencing.