James Hogan of Detroit has pleaded guilty to the attempted murder of a transgender sex worker during a rendezvous earlier this year that prosecutors and advocates say came close to ending in that woman’s death.

The trans woman of color identified by the Detroit News as a prostitute was in the backseat of Hogan’s car with him, after he had solicited her for sex, according to the Fair Michigan Justice Project, which worked with the Wayne County district attorney on this case.

Hogan entered his plea last week and faces a hearing on May 16 on the charges of assault with intent to commit murder, and possession of a firearm during the commission of a felony in connection with the January incident.

RELATED: Suspect arrested in NYC murder of the 10th transgender woman of color this year

Although WDIV-TV named the victim with the male name she was given at birth, LGBTQ Nation is withholding that from this report. Hogan shot the victim in the face with a 9 mm handgun while they were engaged in a sex act, according to the station.

He shot three times, first hitting the victim on the left side of her nose, according to court documents.

Hogan told the victim he did it because he was drunk and wanted to kill himself, according to the Detroit News. Crack was also involved, according to reports. “I’m going to give you ’til (the count of) 10 to leave,” she testified.

The victim said despite bleeding profusely she didn’t run, fearing he’d shoot her in the back of the head as soon as she turned around. It was only when Hogan agreed to put the gun down and he let her hold his arms down that she was able to escape, she said.

“I finally get a hold of the lock without looking, opened the door and then I just jet out the car. My pants is down, my coat is in the car. I left my coat. I left the pipe, the crack pipe with some dope in there, all that stuff. I just left all that,” the victim testified.

The victim spent minutes looking for help, finally getting “some guy that I decide to beg that left the crack house” to drive her to Sinai Grace Hospital, but only after the victim “offered to buy him some rocks to drop me off.”

She was hospitalized for several days to treat the gunshot wound to her nose. “She seems as though she’s recovered from her injuries,” said Dana Nessel, president of the Fair Michigan Justice Project. “She had no difficulty speaking, and was lucky the shot didn’t do a great deal more damage.”

Following an investigation by Detroit police, Hogan was arrested on Jan. 22.

Nessel told the paper it was “very clear” that Hogan “solicited (the victim’s) services because she was a transgender woman,” saying “they discussed specific sex acts that could only be performed on a man or a transgender woman.”

“This case highlights the mortal danger faced by transgender individuals in Michigan,” said Fair Michigan’s transgender outreach coordinator Julisa Abad.