Ruben Espinosa was a photographer for a number of outlets, including the leading newsweekly Proceso and Agencia Cuartoscuro.
His killing brings to the forefront the duress and danger under which many Mexican journalists work.
Espinosa had left the coastal state of Veracruz last month because he felt threatened. He went to the capital, where he sought refuge, but didn't shy away from doing interviews with other media about what his experiences.
"I had to come (to Mexico City) in a context of violence that journalists in Veracruz have to live under," Espinosa said in his last recorded interview
He described Veracruz -- where 13 journalists have been killed in the past five years -- as a place where "it's complicated to do journalism."
The bodies of the five shooting victims were discovered on Friday in an apartment in the Narvarte neighborhood in south-central Mexico City, the prosecutor's office said.
Four women and one man were found shot dead inside, the prosecutor's office said, without naming the victims. They were from 18 to 40 years old.
A press freedom advocacy group, Article 19, spoke with Espinosa's family members, who confirmed that they identified the photographer's body at the coroner's office on Saturday.
There were signs of severe blows to the journalist's face, the group said.
Espinosa's employer, Proceso, reported that the photographer had been shot twice.
The prosecutor's office said they found the bodies of two women in one room of the apartment, a man and a woman in another room and a fourth woman identified as the apartment's housekeeper in a bathroom. Three of the woman lived in the apartment, officials said. The names of the four women were not immediately released.
Espinosa's family told Article 19 that they last heard from the photojournalist at 2 p.m. Friday. When they didn't hear from him later, they alerted the advocacy group, which in turn alerted authorities.
In interviews, Espinosa had explained why he left Veracruz.
In June, Espinosa told Article 19 that he noticed he was being followed in several locations and given menacing looks. At least one of the people who appeared to be following him snapped photos of him. Espinosa told the advocacy group that he also saw men standing outside his home in Veracruz, and who gave him menacing looks before walking away.
In the last interview he recorded, with the outlet RompeViento, he said simply, "I had to leave because of acts of intimidation."
"I had to leave because it was not a direct threat, but I got the message. It was just recently when students were attacked and brutally beaten with machetes. In these situations, we can't do less with any type of aggression or intimidation because we don't know what might happen. Veracruz is a lawless state," Espinosa told the outlet.
According to Proceso, Espinosa had faced close calls in the past. In 2013, uniformed state police beat him during a clash between protesting teachers and authorities in Veracruz.