Cesar Suarez, who launched the high-profile investigation of organised transnational crime, was shot while driving a vehicle in Guayaquil, considered to be the most dangerous city in Ecuador.
The country’s attorney general, Diana Salazar, said on social media: “The criminals, the terrorists, will not hold back our commitment to Ecuadorian society.
“We call on the forces of order to guarantee the security of those who are carrying out their duties.”
Ms Salazar said her office was conducting a preliminary investigation into the murder, and expressed grief for the prosecutor’s family.
Ecuador has recently been hit by a dramatic surge in violence, including prison riots, explosions in several cities, and the dramatic attack on the studio of TC Television in Guayaquil.
Heavily armed gunmen stormed the studio of the TV station during a live broadcast just over a week ago. At least 13 suspects have been arrested in connection with the attack, which involved pistols, shotguns, machine guns, grenades and sticks of dynamite.
The attack prompted Ecuador’s president, Daniel Noboa, to declare that the country is in an “internal armed conflict” amid a spate of seemingly coordinated killings and other crimes tied to drug trafficking.
President Noboa instituted a 60-day state of emergency, including curfews at night, and ordered that 22 criminal gangs be designated terrorist organisations.
Suarez was also in charge of the high-profile “Metastasis” investigation, an operation to root out narco-corruption involving an Ecuadorian drug lord who allegedly received favourable treatment from judges, prosecutors, police officers and other high-ranking officials.
The investigation led to raids across Ecuador and 30 arrests, with charges raised against judges for allegedly giving favourable rulings and police officers for tampering with evidence.
Ecuador was considered one of the most peaceful countries in Latin America until about three years ago. But criminal activity has permeated both affluent and working-class neighbourhoods, with a surge in professional hitmen, kidnappers and extortionists, and a significant number of thieves and robbers.
Over the past five years, Ecuador has experienced a dramatic surge in its murder rate, which reached a record high of 7,878 killings last year as Mexican and Colombian drug cartels settled into coastal cities like Guayaquil, from where cocaine produced in neighbouring Colombia and Peru is shipped overseas.