The man, Joseph Schreiber, 32, pleaded no contest — effectively a guilty plea — during a hearing on Monday in St. Lucie County.

Image

Joseph Schreiber.CreditSt. Lucie County Sheriff's Office, via Reuters

Mr. Schreiber, who had a previous criminal record and who had posted anti-Islamic views on social media, told detectives he set fire to the Islamic Center of Fort Pierce on the anniversary of the Sept. 11 terror attacks, which in 2016 also fell on Eid al-Adha, an important Muslim holiday, Assistant State Attorney Steve Gosnell said.

The mosque was so badly damaged — photos published online show a gaping hole in the roof and an interior burned to a crisp — that it is expected to be relocated.

The mosque, about an hour’s drive north of Palm Beach, was occasionally attended by Mr. Mateen, the Islamic State supporter who shot and killed 49 people and wounded 53 others on June 12 at the Pulse nightclub in Orlando, the deadliest mass shooting in modern American history.

Before Mr. Schreiber was sentenced, he read aloud a lengthy statement in which he said the arson had been driven by anxiety, not hate. Florida, he said, could be targeted in another terrorist attack.

“My message is this to all the Muslim communities on the face of the Earth: Make peace with America and make peace with Israel and stop the killings, stop the attacks,” he said.

Mr. Gosnell, the prosecutor in the case, said Mr. Schreiber had told detectives that he believed Muslims were “trying to infiltrate our government” and that “the teaching of Islam should be completely illegal.”

Mr. Schreiber’s sentence was based on his previous criminal record and on arson evidencing prejudice, essentially a hate crime in Florida, the prosecutor said.

The Sunni mosque is central to Islamic life in Fort Pierce, but it has drawn scrutiny in recent years as a place of worship for young men who staged terror attacks.

In addition to the connection with Mr. Mateen, the Islamic Center had been a frequent stop for Moner Mohammad Abusalha, who carried out a suicide bombing in 2014 in Syria. The F.B.I. director, James B. Comey, said the men had known each other casually.