By Brendan Pierson

NEW YORK (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.

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)

Lucas Jackson / Reuters