A former City Council candidate in St. Paul, Minn., has been sentenced to probation after pleading guilty to posting a topless photo of his estranged wife to his campaign website during his run for office last July.

David Martinez, 39, was ordered to serve two years' probation and to complete a mental health evaluation, avoid drugs and alcohol and refrain from having contact with his wife. He could face about a year in prison if he breaks those terms.

CITY COUNCIL CANDIDATE ACCUSED OF POSTING WIFE'S TOPLESS PIC AFTER RESTRAINING ORDER ISSUED: REPORT

Martinez, an Independent, posted the photo on his campaign website one day after his wife filed for a protection order against him, according to court documents. He was charged with non-consensual dissemination of private sexual images for violating the state's revenge porn law.

Martinez lost the city council race in a special election. (Twitter)

Martinez lost the city council race in a special election. (Twitter)

The 39-year-old originally denied posting the photo and claimed his campaign website had been hacked, the Duluth News Tribune reported. Martinez pleaded guilty in March as part of a deal that saw the felony charge lessened to a gross misdemeanor.

CLICK HERE TO GET THE FOX NEWS APP

During the campaign, Martinez was accused of domestic abuse, ejected and banned from Target Field — home of the Minnesota Twins baseball team — and arrested and banned from St. Paul public libraries, Twin Cities Pioneer Press reported at the time.

Martinez went on to lose the city council race in a special election.

The Associated Press contributed to this report.