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.
He told police he wanted to watch the premises burn down, confessing to officers: "I did it."
Johnson, 49, admitted two charges of wilful fire-raising, aggravated by religious prejudice, on August 28 when he appeared at the High Court in Edinburgh last month.
Returning to the court for sentencing on Thursday, 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 unemployed Johnson happened to come across the building.
The court heard that on the evening of August 27, Johnson bought a container and then fuel worth £3.51 from a local petrol station.
Shortly before 5am on August 28, a man heading to the temple to pray spotted fire had taken hold on one side of one 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.
Around a couple of hours later, the caretaker at Leith Methodist Church noticed a smell of petrol and burning and cleaned up the area around the front door after realising there was no fire damage of note.
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 then 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 August 30. 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.
"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."
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 ahead of sentencing.
Speaking after the hearing, Detective Inspector Grant Johnston, of Gayfield CID in Edinburgh, said: "Paul Johnson showed absolutely no concern for the safety or wellbeing of those in or around either place of worship when he started these fires.
"As a result of a swift police investigation, Johnson was quickly traced and arrested in connection with the fire and has now been given a custodial sentence.
"We treat all hate crime incidents with the utmost seriousness and whenever such offences occur, we will conduct a thorough inquiry to bring those responsible to justice."
Stay up to date with the latest news stories from a Christian perspective. Sign up to our daily newsletter and receive more stories like this straight to your inbox every morning.