NEW YORK, Sept 25 (Reuters) - Former U.S. Congressman Anthony Weiner was sentenced to 21 months in prison on Monday for sending sexually explicit messages to a 15-year-old girl, setting off a scandal that played a role in the 2016 U.S. presidential election.

Weiner, 53, started to cry as soon as the sentence was announced by U.S. District Judge Denise Cote in Manhattan. He pleaded guilty in May to transferring obscene messages to a minor, and agreed he would not appeal any sentence of 27 months or less.

RELATED: A look at Anthony Weiner's sexting scandal



15 PHOTOS Anthony Weiner sexting scandal See Gallery Anthony Weiner sexting scandal New York mayoral candidate Anthony Weiner attends a campaign event in the Rockaways section in the Queens borough of New York July 31, 2013. Weiner, 48, had surged into the lead in polls for the Democratic Party primary before revelations last week that he had sent more sexually explicit messages to at least one woman after he resigned and promised to change his behavior. REUTERS/Eric Thayer (UNITED STATES - Tags: POLITICS ELECTIONS) NEW YORK, NY - JUNE 16: U.S. Rep. Anthony Weiner (D-NY) announces his resignation June 16, 2011 in the Brooklyn borough of New York City. The resignation comes ten days after the congressman admitted to sending lewd photos of himself on Twitter to multiple women. (Photo by Mario Tama/Getty Images) NEW YORK - JUNE 12: A group of Congressman Anthony Weiner's constituents rally for his resignation outside his Kew Gardens office June 12, 2011 in the Queens borough of New York City. Weiner, who has refused to resign, requested a temporary leave of absence from the House of Representatives for professional treatment in the wake of his internet messaging scandal. (Photo by Michael Nagle/Getty Images) U.S. Representative Anthony Weiner (D-NY) announces that he will resign from the U.S. House of Representatives during a news conference in Brooklyn, New York, June 16, 2011. Weiner resigned on Thursday over a weeks-long Internet sex scandal, succumbing to bipartisan calls for him to step down. REUTERS/Mike Segar (UNITED STATES - Tags: POLITICS) WASHINGTON - MAY 31: U.S. Rep. Anthony Weiner (D-NY) speaks to the media regarding a lewd photo tweet May 31, 2011 on Capitol Hill in Washington, DC. A close-up photo of underwear of a man was tweeted from Weiner's Twitter account addressed to a college student in Seattle. The photo was deleted soon after and Weiner has claimed his account was hacked. (Photo by Alex Wong/Getty Images) WASHINGTON - MAY 31: U.S. Rep. Anthony Weiner (D-NY) leaves after he spoke to the media regarding a lewd photo tweet May 31, 2011 on Capitol Hill in Washington, DC. A close-up photo of underwear of a man was tweeted from Weiner's Twitter account addressed to a college student in Seattle. The photo was deleted soon after and Weiner has claimed his account was hacked. (Photo by Alex Wong/Getty Images) Former porn actress Ginger Lee (L) and her attorney Gloria Allred (R) depart a news conference in New York, June 15, 2011. Lee said on Wednesday she had an e-mail relationship with embattled Representative Anthony Weiner and that he urged her to lie about their exchanges in the hope that a scandal surrounding him would die down. REUTERS/Brendan McDermid (UNITED STATES - Tags: POLITICS CRIME LAW) Sydney Leathers, one of the women at the center of the scandal, spoke exclusively to Inside Edition about growing speculation that Donald Trump is planning to dredge up the sexting scandal all over again because Abedin is often regarded as Clinton's closest confidante. Huma Abedin, an aide to U.S. Secretary of State Hillary Clinton (C), is pictured during a House Appropriations Committee hearing on Capitol Hill in Washington, in this March 10, 2011 photograph. Abedin, the wife of U.S. Representative Anthony Weiner (D-NY), ensnared in a sex scandal for sending lewd pictures of himself over the Internet, is pregnant, the New York Times reported on June 8, 2011. REUTERS/Hyungwon Kang/Files (UNITED STATES - Tags: POLITICS) NEW YORK, NY - JULY 26: Anthony Weiner, a leading candidate for New York City mayor, pauses while speaking with reporters in Staten Island on a visit to homes damaged by Hurricane Sandy on July 26, 2013 in New York City. It was recently revealed that Weiner engaged in lewd online conversations with a woman after he resigned from Congress for similar previous incidents. (Photo by Spencer Platt/Getty Images) A Times Square newstand with local papers displaying headlines July 24, 2013 about the latest sexting scandal involving New York City mayoral candidate Anthony Weiner. Weiner on Tuesday admitted sending lewd texts and photographs under the moniker 'Carlos Danger' to a young woman after resigning from Congress over a similar scandal. According to news website 'The Dirty,' Weiner, 48, used the name to contact the woman on Facebook and establish an online relationship with her which involved the exchange of intimate photographs. In a statement from his campaign team, Weiner confirmed that the latest allegations were substantially true but tried to present them as having been covered by his previous confession. AFP PHOTO / TIMOTHY CLARY (Photo credit should read TIMOTHY CLARY/AFP/Getty Images) The ABC Good Morning America Times Square Ticker flashes news July 24, 2013 about the latest sexting scandal involving New York City mayoral candidate Anthony Weiner. Weiner on Tuesday admitted sending lewd texts and photographs under the moniker 'Carlos Danger' to a young woman after resigning from Congress over a similar scandal. According to news website 'The Dirty,' Weiner, 48, used the name to contact the woman on Facebook and establish an online relationship with her which involved the exchange of intimate photographs. In a statement from his campaign team, Weiner confirmed that the latest allegations were substantially true but tried to present them as having been covered by his previous confession. AFP PHOTO / TIMOTHY CLARY (Photo credit should read TIMOTHY CLARY/AFP/Getty Images) A Times Square newstand with local papers displaying headlines July 24, 2013 about the latest sexting scandal involving New York City mayoral candidate Anthony Weiner. Weiner on Tuesday admitted sending lewd texts and photographs under the moniker 'Carlos Danger' to a young woman after resigning from Congress over a similar scandal. According to news website 'The Dirty,' Weiner, 48, used the name to contact the woman on Facebook and establish an online relationship with her which involved the exchange of intimate photographs. In a statement from his campaign team, Weiner confirmed that the latest allegations were substantially true but tried to present them as having been covered by his previous confession. AFP PHOTO / TIMOTHY CLARY (Photo credit should read TIMOTHY CLARY/AFP/Getty Images) Disgraced former US congressman Anthony Weiner, running for mayor of New York, fields questions at an after-hours event in the Chelsea district of New York city on August 12, 2013, organized by the Buzzfeed.com website. Opinion polls show Weiner lagging in the race for City Hall after he acknowledged that he kept on sending explicit Internet messages to women even after he resigned from Congress in a sexting scandal. AFP PHOTO / Robert MacPherson (Photo credit should read Robert MacPherson/AFP/Getty Images) FILE PHOTO -- New York mayoral candidate Anthony Weiner and his wife Huma Abedin attend a news conference in New York, July 23, 2013. REUTERS/Eric Thayer/File Photo Up Next See Gallery Discover More Like This HIDE CAPTION SHOW CAPTION of SEE ALL BACK TO SLIDE

Weiner's lawyers had asked that he be sentenced to probation rather than prison, saying he acted out of the "depths of an uncontrolled sickness" and was now being treated.

The investigation into Weiner’s exchanges with a North Carolina high school student roiled the 2016 U.S. presidential campaign in its final days, when authorities found emails on Weiner’s laptop from his wife Huma Abedin, an aide to Democratic presidential candidate Hillary Clinton. Abedin has filed for divorce. Weiner wore his wedding band at the sentencing.

The discovery of the emails prompted James Comey, then director of the Federal Bureau of Investigation, to announce in late October that the agency was reopening its investigation into Clinton’s use of a private email server while she was U.S. secretary of state.

Clinton has said the announcement contributed to her upset loss to Republican Donald Trump, who had accused her of endangering national security by using the private server.

President Trump fired Comey in May amid the FBI’s probe into whether his campaign colluded with Russia to defeat Clinton, a claim the president has denied.

Weiner represented parts of New York City in the U.S. House of Representatives for 12 years before resigning in 2011, after it emerged that he had exchanged sexually explicit messages with adult women.

In 2013, Weiner ran for New York City mayor, but dropped out of the race when more lewd messages became public. (Reporting by Brendan Pierson in New York; Editing by Diane Craft and Jeffrey Benkoe)

More from :

Feds: Anthony Weiner deserves two years in prison in sexting case

Anthony Weiner, once a congressman, faces jail as a sex offender

Anthony Scaramucci claims Tom Brady once dated Ivanka Trump