Image copyright Reuters Image caption The deadly riot broke out at the Lee Correctional Institution in South Carolina

Seven prisoners have been killed and at least 17 others injured in a riot at a maximum security prison in the US state of South Carolina, officials say.

Violence erupted at the prison facility on Sunday evening and was brought under control in the early hours of Monday.

"This was all about territory, this was about contraband," the South Carolina Department of Corrections said.

The deaths were the result of stabbings. All prison guards and law enforcement staff were said to be safe.

"These folks are fighting over real money and real territory while they are incarcerated," said Bryan Stirling, director of the South Carolina Department of Corrections.

Over a period of almost eight hours, there were "multiple altercations" at three housing units at the Lee Correctional Institution, the department tweeted on Monday.

"The incident at Lee CI resulted in 17 inmates requiring outside medical attention and seven inmates were killed," the department added.

Several inmates were stabbed or slashed with homemade knives, while the remainder appeared to have been beaten, Lee County Coroner Larry Logan told the Associated Press.

The department said that all staff at the institution in Bishopville were later "accounted for" and that an investigation was under way.

Lee County fire and rescue service also provided assistance with the incident and tweeted images of the vehicles involved in the response.

The Lee Correctional Institution, which was opened in 1993 about 50 miles (80 km) east of the state capital Columbia, houses more than 1,500 violent male offenders and inmates with behavioural issues.

In March, an officer at the prison was "overpowered" and held by inmates who took control of part of the building for more than an hour.

Deadly prison riots are relatively rare in the US.