Daniel Finnerty, 16, sprayed a crucifixion cross on the wall of All Saints Church in Fleet with deodorant before setting it alight in June. He also set alight a Bible and left it on the altar.
A class of ballet dancers aged five years old had to be immediately evacuated when the fire struck.
Winchester Crown Court heard that Mr Finnerty had a poor upbringing, suffered from some mental health disorder, and had consumed illegal drugs and alcohol since he was 15.
He was connected to the crime via CCTV footage.
All Saints Church priest Mark Hayton said the congregation is praying for Daniel Finnerty.