The murder of the judge Marcos Mendoza occurred in the community of Montecristi in western Ecuador, which has problems with several drug cartels.
At least 15 judges or prosecutors have been killed in the country since 2022, according to Human Rights Watch. Ecuador, which was once considered one of the safest countries in Latin America, has in recent years seen a dramatic increase in deadly violence.
The Ecuadorian judges' association says in a statement that the "shocking" murder highlights the vulnerability of the country's judges.
They "are exposed to pressures, threats and risks every day when performing their duties", the association states.