A 12-year-old boy was among 17 people killed as gunmen fired into a bar in Ecuador, the latest mass shooting in a country ravaged by drug violence.

Ecuador's attorney general's office said 14 others were injured in the attack on Sunday night at La Clínica bar in El Empalme.

Police Major Oscar Valencia said the gunmen travelled in two pickup vehicles and "opened fire on everyone" with "pistols and rifles", before firing on another group as they fled the scene.

He said the child who was killed had ran for over a kilometre before collapsing and dying from gunshot wounds.

Images from the scene published in local media showed several bodies on the street covered in white sheets.