NEW YORK — Cesar Sayoc, the Florida man who mailed explosive devices to prominent Democrats and media figures, was sentenced Monday to 20 years in prison.

Prosecutors had called for a life sentence for Sayoc, a 57-year-old pizza delivery man and strip club worker who pleaded guilty to mailing 16 inoperative pipe bombs days before the midterm elections last fall.

“I am beyond so very sorry for what I did,” Sayoc told U.S. District Judge Jed Rakoff. “Now that I am a sober man, I know that I was a sick man. I should have listened to my mother, the love of my life.”

Prosecutors and defense lawyers spent much of the hearing wrangling over how dangerous the packages truly were to those who handled them.

“What counts is what he did, and what he intended at the time that he did it,” Rakoff said before imposing the sentence.

Sayoc’s lawyers had pushed for a 10-year sentence, saying he was using large quantities of steroids when he became delusional in his support for President Donald Trump.

“He truly believed wild conspiracy theories he read on the internet, many of which vilified Democrats and spread rumors that Trump supporters were in danger because of them,” Sayoc’s lawyers wrote to the judge. “He heard it from the President of the United States, a man with whom he felt he had a deep personal connection.”

Trump and his allies have repeatedly pushed back against the idea that his incendiary rhetoric could be linked to extremist violence.

Sayoc’s sentencing comes just two days after the massacre of nearly two dozen people inside a Walmart in El Paso, Texas, a horrific act of violence allegedly undertaken out of anger toward immigrants. Several Democrats seeking to challenge Trump in the 2020 election have connected the president’s rhetoric to Saturday’s bloodshed.

Weeks before the 2018 congressional elections, packages were mailed to Hillary Clinton, former President Barack Obama, and actor Robert De Niro, among others.

The spree of suspicious packages prompted a nationwide manhunt for the suspect, and the trail eventually led investigators to Sayoc, who lived out of a white van plastered with pro-Trump images. He worked as a DJ or bouncer at strip clubs, and was once charged with threatening the local power company.

After his arrest, Sayoc pleaded guilty to 65 counts. Officials said he sent 16 devices to 13 people across the country.

At Sayoc’s guilty plea, he insisted the devices were “intended to look like pipe bombs,” but that he did not mean for them to detonate. Pressed by the judge to explain further, Sayoc added, “I was aware of the risk that they would explode.”

Federal officials called the wave of potential explosive devices sent in October a “domestic terror attack” and accused Sayoc of endangering numerous lives. Prosecutors said Sayoc began searching for the homes of some targeted as early as last July 2018 and continued into the fall.

The first package was found Oct. 22, and the investigation and anxiety grew as more devices were identified in the days that followed. CNN’s New York offices were evacuated when a package addressed to John Brennan, the former CIA director, was found in the mail room, a situation that played out on live television. Packages were soon found in Florida, Delaware and California.

Within days, authorities closed in on Sayoc outside an auto supply store in Plantation, Florida, after finding what Christopher Wray, the FBI director, said was a fingerprint on one of the envelopes containing a device. Wray also said there were potential DNA matches connecting Sayoc to some of the devices.

While none of the devices detonated, Wray said they were “not hoax devices.”