Nine people have been killed in clashes between the Libyan army and an Islamist militia in the restive city of Benghazi, officials say.

Gunfire could be heard from the early hours of the morning and smoke was seen rising in part of the city.

Casualties were reported among both the army and Ansar al-Sharia, an armed Islamist group suspected of killing US ambassador Christopher Stevens in 2012.

The government has struggled to contain militias in control of parts of Libya.

The BBC's Rana Jawad in Tripoli says the latest fighting is seen as one of the most serious and direct confrontations between official forces and this militia.

Ten days ago, Prime Minister Ali Zeidan called on all militias to leave the capital, Tripoli, after fatal clashes between militiamen and protesters.

The militias took part in the uprising that led to the fall of Col Muammar Gaddafi in 2011 but have been told by the interim government to disband or join the army by the end of the year.

Reports from Libya's second city early on Monday spoke of explosions and gunfire in the Ras Obeida area.

The fighting erupted after a civilian was stopped at a checkpoint manned by Ansar al-Sharia because he was carrying a weapon, a military source told the BBC. The man was allegedly beaten, prompting a special forces unit to move in.

Acting Interior Minister Sidiq Abdel-Karim told Libyan TV that nine people had been killed and another 49 wounded in the clashes.

The injured were taken to Jala hospital and several civilians were said to be among those hurt.

Profile: Ansar al-Sharia

Group's name translates as Partisans of Islamic law (Sharia)

One of several extremist Islamist groups believed to be active in Libya

Attempted to set up an Islamist state in eastern Libya in 2011, but failed

Thought to have connections to foreign Islamist networks

"The latest events show the urgent need to implement law 53 to disband all [illegally] armed groups. The army and all its forces are carrying out its legal duties," Mr Abdel-Karim said.

He warned the army was a "red line" not to be crossed.

Heavy but intermittent clashes began at about 02:00 local time (midnight GMT) and continued until late morning in various areas of the city. "This is the end of Ansar al-Sharia," a military source told the BBC.

The army has been driving around Benghazi urging residents to stay at home. An urgent appeal has been broadcast for blood donors in the city, reports say.

"People are going about their business but schools are closed and the university has suspended classes until things settle down," Benghazi resident Adam Jhani-Stephens told the BBC.

Local TV said officials had begun a meeting in an attempt to bring the violence to an end.

Benghazi, one of Libya's most volatile areas, was where the uprising of Col Gaddafi began. It was also where the US ambassador and three other Americans were killed in an attack on the US consulate on 11 September 2012.

Ansar al-Sharia, which is believed to have ties with foreign Islamist groups, has been linked to a series of attacks in eastern Libya.

Media playback is unsupported on your device

Media captionJohn Kerry, speaking on Sunday: "This is a moment of opportunity"

Several Islamist groups have formed from the anti-Gaddafi rebels and they have been blamed for recent murders in nearby Derna. A judge, two traffic police and a tribal chief have died in the port city east of Benghazi in just over a week.

Last month, Prime Minister Zeidan was abducted and held for several hours by militiamen in a Tripoli hotel.

After talks in London on Sunday with US Secretary of State John Kerry and UK Foreign Minister William Hague, Mr Zeidan said Libya had done a great deal "to get rid of the militias".

Mr Kerry told reporters that Libya had gone through great turmoil, particularly in recent weeks, but spoke of a moment of opportunity.

"The prime minister informed us of a transformation that he believes is beginning to take place and could take place because the people of Libya have spoken out and pushed back against the militias," he said.