At least 31 inmates have been found dead in a prison in southern Ecuador, including 27 who had been hanged, according to officials.

Four prisoners were killed and more than 30 injured in clashes between rival gang members in El Oro prison in the city of Machala in the early hours of Sunday.

Hours later, security guards who were alerted to a fresh outbreak of gang violence discovered the others who had been hanged on the building's third floor, as reported by Ecuador's prison service.

The country’s overcrowded prisons have seen a series of deadly riots and gang fights that have resulted in hundreds of inmate deaths in recent years.

Ecuador's prison service, known by its initials as Snai, stated that the clashes were triggered by plans to relocate some inmates to a newly built prison.

El Oro prison previously witnessed violence in September when 13 inmates and a guard were killed due to gang clashes.

Families of prisoners have urged the authorities to enhance security measures inside the prison, and residents of Machala have long called for the relocation of the facility, which sits in the city center.

The government, led by President Daniel Noboa, earlier announced the construction of a new maximum security jail in Santa Elena province.

The new facility, named El Encuentro, is expected to open in late November and will include advanced security features, according to the interior minister.

Persistent gang activity has been a major contributor to rising violent crime in Ecuador, with two notorious groups recently designated as Foreign Terrorist Organizations by the US Department of State.