A 32-year-old man with a long and violent criminal history has been charged with grabbing an intoxicated 23-year-old woman behind a south Minneapolis bar as she left after closing time and ­raping her at gunpoint.

Demarcus N. Chaney, of Minneapolis, was arrested and charged Tuesday with two counts of first-degree criminal sexual conduct in the attack on June 24 behind Mortimer’s bar, near Lyndale Avenue and W. 22nd Street. Chaney remains jailed in lieu of $500,000 bail.

A little more than two weeks after the attack, police released photos of two men, described as “persons of interest,” that were captured on video at the World of Wireless store at Lyndale and W. Lake Street as they attempted to sell the woman’s cellphone on the day of the assault.

The photos prompted a probation officer and a corrections officer to come forward with information about the suspect, police said.

The other man in the photos was arrested but released once DNA testing pointed to Chaney as the culprit, police added.

According to the criminal complaint:

Police met about 2:40 a.m. near the bar with the woman and a friend. The officers were told the victim had a gun put to her head and then forced by her attacker to have intercourse. The man also stole her cellphone.

The woman went on to tell police that she was intoxicated and was “having difficulty recalling specific details,” the complaint read. She remembered leaving the bar but couldn’t recall whether she was alone.

She said the suspect approached from the front and attempted some small talk before grabbing her by her arms and pulling her into a grassy area.

He had a handgun to her head, was threatening to kill her and then raped her.

With DNA from the semen, authorities made a match with Chaney’s DNA stored on the state’s convicted offender database.

In 1999 and at age 18, Chaney was charged with being one of two men who were charged with burglary, robbery and kidnapping for allegedly breaking into the south Minneapolis home of two women about 4 a.m. He pleaded guilty to burglary.

Chaney’s criminal history in Minnesota also includes five convictions for theft, one for drunken driving and another for disorderly conduct, according to court records.