Most of all, those who knew Kedarie said he never seemed to be struggling with issues about his gender identity or his sexual orientation or what other people might think about any of it. “Kedarie was just Kedarie, and that was that,” said Tremell Jones, 17, a friend who was with him the night he disappeared.

Not long before midnight on March 2, 2016, the police received reports of gunshots in an alley behind Walnut Street. They found a body in the tall grass. Kedarie was shot twice in the chest. He had no shoes on, and his shirt was pushed up. A bleach bottle was nearby.

Prosecutors say Mr. Sanders-Galvez and a cousin, Jaron Purham, 26 — both of whom lived most of the time in the St. Louis area — had observed Kedarie only a few hours earlier in Burlington’s Hy-Vee grocery store, where he liked to hang out and use the Wi-Fi. Surveillance video from the store showed him dressed that evening in long hair extensions, a pink headband and leggings. Just before Kedarie vanished, when he left the store and stopped at a friend’s home to borrow bras from her, he mentioned that he was worried about someone following him, the friend has testified.

The prosecutors have not said exactly what they believe took place in the less than two hours before Kedarie was found dead, except to say that the two men liked women and had brought him back to a house where they had been staying and where they often had sex with various women. The prosecutors’ suggestion, though not explicitly made before jurors, was that Mr. Sanders-Galvez and Mr. Purham thought that Kedarie was a woman and grew enraged and violent when they discovered otherwise. Kedarie’s backpack and shoes were found in the house.

Lawyers for Mr. Sanders-Galvez, who has sat silently in a suit and tie in the courtroom in Keokuk, Iowa, south of Burlington, where the trial is taking place, have yet to offer a defense. In an interview, one of the defense lawyers, Curtis Dial, said simply that his client “did not do it. That’s it.”

In charging the men with murder — but not hate crimes — the local authorities concluded that the killing did not amount to a hate crime under Iowa’s statute, which bars committing crimes against people for reasons that include race, religion and sexual orientation. Gender identity is not covered by the state’s statute, and efforts last year to add it died in the Republican-held state House. A first-degree murder conviction, the local authorities noted, carries a serious penalty: life in prison.