They met in 2012, became friends and soon were dating. The D.C. woman was 25 when she met Lamont Roberts. The couple went to cabarets, dinners and movies.

During their romance, Roberts encouraged his girlfriend to let him take nude photographs of her that he kept on his phone. She agreed, but insisted that he delete them afterward. She thought Roberts erased them.

But three years later, when the two broke up, prosecutors said Roberts launched a month-long campaign of harassment using the explicit photographs. He left voice mails, emails and text messages threatening to distribute 8.5-inch-by-11-inch prints of the photos around the woman’s home and workplace if she didn’t come back to him. Then he followed through.

“He stalked her and made her life a living nightmare with photographs of her vagina,” prosecutor Jessi Camille Brooks told a D.C. Superior Court judge Wednesday, as the former girlfriend sat in the back of the courtroom.

Roberts, convicted after a November trial, is the first person in the nation’s capital convicted under the District’s 2014 image exploitation law, also known as the revenge porn law.

On Wednesday, Judge Juliet J. McKenna sentenced him to nine years in prison for assault, threats and stalking. Of that sentence, nearly two and a half years were for the five misdemeanor counts of distributing the photographs.

Five times in October 2015, prosecutors said, Roberts posted the photos on the front door of his former girlfriend’s house, which she shared with her young children and her mother. It was her mother who discovered the photographs one morning. Roberts also posted pictures on the gate outside the home, where her neighbors could see them as they walked by. Roberts put one on her car’s windshield. He also went to her job and stood in the lobby with a copy of a photograph, which she grabbed from him.

Various versions of so-called revenge porn laws exist in 35 states, according to the nonprofit Cyber Civil Rights Initiative. They are designed to make it a criminal offense to distribute intimate photos or videos of a person without their consent, or to use such images in an act of revenge.

Mary Anne Franks, vice president and legislative and technology director for the Cyber Civil Rights Initiative, said the group is hoping that a law will be introduced to Congress before the end of the year that will make distributing such images across state lines a federal offense. Franks said the biggest challenge with such laws has been concerns over free speech rights. Another hurdle, she said, has been legislators who blame the victim for even agreeing to such photographs or videos.

Franks said she considers distributing such private photos as a way to control or punish to be “a form of domestic violence.”

In 2014, Franks testified before the D.C. Council when the city’s bill was introduced. She now criticizes the District’s law because she said the law requires prosecutors to prove intent to harm. That could be challenging, she said, unless there is evidence such as a voice mail or text message to prove that the perpetrator shared the images to harm the victim.

D.C. Council member Charles Allen (D-Ward 6), chairman of the council’s Judiciary and Public Safety committee, said authorities will review how future cases are handled to determine whether the law needs to be “tweaked.” Allen said the purpose of the law was to catch up to the rapidly changing Internet.

“This is an emerging area of the law, the world of cybertechnology. The law has to catch up in many instances,” Allen said.

Under D.C.’s image exploitation law, defendants can be charged with either a misdemeanor or a felony depending on the details of the case. Roberts was convicted of misdemeanors. Defendants who post such photographs on the Internet, or a place where six or more people could see them, could face a felony charge.

The misdemeanor charge carries a maximum of 180 days in jail, a $1,000 fine or both. The felony offense carries a maximum of three years in prison.

Roberts will have to wait before he begins serving his prison term: He is serving a six-year sentence in a prior federal drug case, a charge he picked up after his arrest in the photo stalking case.

In court Wednesday, Roberts, 46, wearing an orange D.C. jail jumpsuit, stood next to his attorney and apologized to the court and to his former girlfriend. He told the judge that he is in a drug treatment and a domestic violence prevention program in the jail.

“I made a mistake and I apologize,” Roberts said.

McKenna placed Roberts on three years of supervised probation and ordered him to stay away from his former girlfriend. The judge also ordered Roberts to pay $650 in fines.

“I’ll have my mother pay it,” he said before the marshals led him out of court.

Jennifer Jenkins contributed to this report.