MEXICO CITY — Faced with a wave of deadly attacks against journalists, the president of Mexico has vowed to take concrete steps to ensure the safety of journalists in his country, including removing the lead prosecutor responsible for investigating crimes against the freedom of expression.

Last year, 11 Mexican journalists were killed, the most in more than a decade, and several more murders have already been recorded in 2017. And yet there is near total impunity for the attackers, in part because the special office responsible for prosecuting cases involving the freedom of expression rarely brings anyone to justice for the crimes.

Since its creation in 2010, the office has examined more than 800 cases of serious crimes but has won only two convictions. Ricardo Nájera, the lead prosecutor, has repeatedly failed to take on cases, including homicides, in which evidence exists that the victim’s reporting and writing had provoked the wrath of attackers.

President Enrique Peña Nieto’s pledge to replace Mr. Nájera and ensure funding for a federal protection program for threatened journalists follows several critical reports accusing the government of complicity in attacks on the news media and of an inability — or unwillingness — to investigate cases.