The former St. Paul City Council candidate whose erratic behavior landed him in jail several times this year was charged Wednesday with allegedly posting a nude photo of his estranged wife online.

David Martinez, 39, was charged in Ramsey County District Court with one felony count of nonconsensual dissemination of private sexual images.

According to the complaint: Martinez’s estranged wife reported on July 14 that he had posted a nude photo of her on his website. A neighbor had alerted her to the image, which was accompanied by a link to an order for protection that the estranged wife had filed against Martinez. It had been served on him “a short time” before the image was posted.

Police investigating the incident found that the image appeared on a web page called “David Martinez for City Council, Ward 4.”

Martinez’s alleged post, entitled “Transparency,” included text that claimed the allegations in the order for protection were fabricated.

“CRAZY!!!,” the post said in part. “… So, I had to call for a Police escort, to my own home, so I could [pick] up my personal belongings.”

The alleged victim said Martinez had taken the photo on a private beach in Puerto Rico, and that she had not agreed to posting it publicly. The woman’s face was visible in the picture.

Martinez allegedly told police that his account had been “hacked” and denied posting the image. In another interview, he allegedly said he had given the laptop to a “group of three little black kids” on the street, the complaint said.

Martinez was arrested on Aug. 8 for violating the order for protection, and an Apple MacBook Pro that was in his possession was confiscated.

Martinez allegedly told police that he “got it back from the black kid that he gave it to,” the complaint said.

A search of the laptop executed under a warrant recovered several hundred thousand images, including the nude photo of Martinez’s estranged wife, the complaint said.

The mother of Martinez’s estranged wife provided police with a text message conversation she had with him about the image.

“David, posting a topless photo … on your blog is pretty juvenile, not to mention disrespectful,” the woman’s mother wrote. “Please remove it.”

“No … Lying to kick me out of my house?!” Martinez allegedly replied. “What the [expletive] is that?”

Martinez lost his run for the council.