Michael Wolfe from Titusville in Florida pleaded guilty to the break-in at the Islamic Society of Central Florida Masjid Al-Munin Mosque in January 2016.
CCTV footage shows the 37-year-old smashing windows and lights with a machete before leaving bacon by the front door.
Wolfe pleaded guilty to criminal mischief to a place of worship with a hate crime enhancement on Tuesday, after a plea deal was arranged with the mosque and the police.
A spokesman for the State Attorney’s Office, Todd Brown, told Florida Today: “He entered a plea deal and plead guilty to vandalising the mosque itself with hate crime enhancement, making it a felony.
“He waived his right to a pre-sentencing investigation.”
In addition to the sentence, Wolfe will remain on probation for a further 15 years after his release.
A charge of armed burglary was dropped in exchange for the guilty plea, Mr Brown said.
According to state records Wolfe has numerous previous convictions for burglary.