A presidential candidate in Ecuador who had been outspoken about the link between organized crime and government officials was assassinated on Wednesday evening at a political rally in the capital, just days before an election that was expected to be dominated by concerns over drug-related violence.

The candidate, Fernando Villavicencio, a former journalist, was gunned down outside a high school in Quito after speaking to young supporters.

“When he stepped outside the door, he was met with gunfire,” said Carlos Figueroa, who worked for Mr. Villavicencio’s campaign and was at the rally. “There was nothing to be done, because they were shots to the head.”

Mr. Villavicencio, 59, was polling near the middle of an eight-person race. He was among the most vocal candidates on the issue of crime and state corruption.

It was the first assassination of a presidential candidate in Ecuador and came less than a month after the mayor of Manta, a port city, was shot to death during a public appearance. Ecuador, once a relatively safe nation, has been consumed by violence related to narco-trafficking in the last five years.

“Outraged and shocked by the assassination,” President Guillermo Lasso wrote on the social media platform X, formerly known as Twitter, late Wednesday, blaming the death on “organized crime.”

The national prosecutor’s office said an hour later, on the same platform, that a suspect had been shot and apprehended amid crossfire with security forces, and had died shortly afterward.