Disgraced former U.S. congressman Anthony Weiner, whose exchange of illicit messages with a teenager wound up playing a role in the 2016 presidential election, was sentenced Monday to 21 months in prison, authorities said.

The penalty marks a stunning downfall for the New York Democrat whose propensity for sending lewd photos to women repeatedly derailed his career in politics, and — in a roundabout way — might also have affected Hillary Clinton's bid to become president.

It was federal authorities' investigation of Weiner that led them to emails of his wife, top Clinton aide Huma Abedin, and the discovery of those emails ultimately caused the FBI, as the election campaign drew to a close, to reopen the probe of Clinton's use of a private email server.

[Computer seized in Weiner probe prompts FBI to take new steps in Clinton email inquiry]

Weiner, 53, pleaded guilty in May to transferring obscene material to a minor, stemming from interactions he had with a 15-year-old who later described the exchanges and released images to the Daily Mail.

The report in September 2016 was notable, although by then, Weiner was well known for such conduct. Abedin had recently separated from her husband, after the New York Post revealed he had sent photos and sexual texts to another woman, and the two are in the process of a divorce. Similar incidents had forced Weiner's resignation from Congress and dashed his hopes of becoming mayor of New York City.

Because of the teen's age, Weiner's exchanges with her would have far more dire consequences. Prosecutors said Weiner knew that the girl was a minor and nonetheless asked her to engage in explicit conduct, which is a crime. They asked for a sentence between 21 and 27 months, arguing that Weiner's misdeeds were "serious and his demonstrated need for deterrence is real."

"The defendant did far more than exchange typed words on a lifeless cellphone screen with a faceless stranger," prosecutors wrote in sentencing papers. "With full knowledge that he was communicating with a real 15-year-old girl, the defendant asked her to engage in sexually explicit conduct via Skype and Snapchat, where her body was on display, and where she was asked to sexually perform for him."

Weiner's defense attorneys argued for a penalty that did not include jail time. They cast the former congressman as a man with an addiction problem and asserted that the teen had reached out to him hoping to generate material for a book deal.

She was paid $30,000 by the Daily Mail for her story, defense attorneys wrote, and an additional $10,000 for a recent appearance on "Inside Edition." The teen also admitted to investigators that "one of her goals" was to affect the outcome of the presidential election, defense attorneys asserted.

For his part, Weiner, who appeared at the sentencing in federal district court in Manhattan on Monday, apologized for what he had done and said he is seeking treatment for his addiction.

"I am profoundly sorry to her," he wrote in a letter to the court. "I was selfish. I have no excuse for what I did to her."

When the investigation into Weiner's exchanges with the girl were publicly revealed, the Trump campaign seized on the news to call for Clinton to return donations from Weiner. The Republican presidential candidate would soon have much more fodder.

In investigating Weiner, the FBI found correspondence between Clinton and Abedin on a device they had not examined previously. That discovery prompted them to reopen their investigation of Clinton's use of a private email server, just weeks before the election. They sought a warrant to examine what they thought might be new emails.

[Emails between Clinton and top aide, but little else, spurred FBI to resume controversial probe]

The FBI had previously concluded that no one should be charged in the case, and agents ultimately found nothing that changed their minds. Still, the revelation that the probe was reopened became a major issue late in the presidential election, and Clinton has blamed it in part for her loss.

Weiner's defense attorneys even noted the FBI's actions in urging a lenient sentence, arguing that the public disclosures of the investigative steps "exacted significant extrajudicial punishment on Anthony and his family."

"Anthony might once have been a punchline, but he is now — to many in this country — something far worse, as a result of Secretary Clinton's loss," defense attorneys wrote.

In a news release, acting Manhattan U.S. attorney Joon H. Kim said Weiner received a "just sentence that was appropriate for his crime."

U.S. District Judge Denise L. Cote said at the hearing, "This is a serious crime that deserves serious punishment."

Weiner is scheduled to report to prison on Nov. 6, prosecutors said.

Arlo Devlin-Brown, Weiner's defense attorney, said in a statement that the defense team was "disappointed" Weiner had been sentenced to prison.

"Judge Cote reasoned that because of Anthony's notoriety, a sentence of imprisonment could discourage others from following in his footsteps," Devlin-Brown said. "We certainly hope this public service message is received, but it has resulted in a punishment more severe than it had to be given the unusual facts and circumstances of this case."