FORT PIERCE, Fla. — An ex-convict who posted anti-Islamic rants online was sentenced to 30 years in prison Monday for setting fire to a mosque that the Orlando nightclub gunman attended occasionally.

Joseph Schreiber pleaded no contest during a hearing before Circuit Judge Steven Levin. He was also ordered to pay $10,000 in restitution, although damages exceeded $100,000. Because he was declared a habitual offender, he could have received a life sentence.

Schreiber confessed to detectives that he set fire to the Islamic Center of Fort Pierce last Sept. 11, the 15th anniversary of the 2001 terrorist attacks. The damage to the mosque was so extensive that the leaders recently announced that it will move.

Omar Mateen was killed by police after opening fire at the Pulse nightclub on June 12 in a rampage that left 49 victims dead and 53 wounded, making it the worst mass shooting in modern U.S. history. Mateen professed allegiance to the Islamic State. His father is among roughly 100 people who regularly attend the mosque.

Schreiber, who is Jewish, posted on Facebook last July that “All Islam is radical” and that all Muslims should be treated as terrorists and criminals.

Prosecutor Steve Gosnell said Schreiber, 32, confessed to detectives that he set the fire, saying he believed Muslims “are trying to infiltrate our government” and that “the teaching of Islam should be completely, completely illegal.”

Before he was sentenced, Schreiber read a written statement where he said the fire was not caused by hate but by his anxiety.

He feared that Florida could be the site of another 9/11, Boston Marathon bombing or Pulse nightclub shooting, he said.

Schreiber then turned to a man he thought was the mosque’s imam and apologized.