Former Congressman and one-time New York City mayoral candidate Anthony Weiner faced up to 10 years in prison for sending lewd texts to a minor, but under a plea deal brokered by his lawyers and the government, he may serve two years or less.

Weiner had pleaded guilty on Friday to transferring obscene material to a minor, or 18 USC §1470, before Southern District Judge Loretta Preska. He agreed not to appeal if he receives a sentence of 21 to 27 months, though the statute carries no minimum sentence, and Weiner may seek a sentence of less than 21 months.