Seven people were killed and more than 20 wounded as gunmen raided the oasis town of Ghadames on the border with Algeria on Wednesday, Libya's government spokesman said.
"There were clashes in the city of Ghadames," Nasser al-Manaa said.
"The number of people killed is seven," Manaa said, adding that more than 20 people were wounded in clashes that erupted in the early morning and centred on the airport.
Six of the raiders were killed along with a resident of Ghadames, which lies 600 kilometres (373 miles) southwest of Tripoli.
That toll was confirmed by a local medical official.
Manaa, who did not identify the assailants, said military forces had entered the city and brought the situation under control. The health ministry, for its part, was providing emergency assistance.
Ghadames officials said the attackers belonged to the Tuareg community.
Saraj al-Din Bubaker, head of the local council, told AFP that "a Tuareg group shelled the city with rocket-propelled grenades, forcing some families to flee."
The Tuareg are dark-skinned Libyans violently displaced from several towns, including Ghadames, after the fall of strongman Moamer Kadhafi in an uprising last year with whose forces they were accused of having sided.
Racism coupled with the belief that Kadhafi recruited sub-Saharan mercenaries have made them a focal point of revenge attacks, rights group say.
Signup to our newsletter and follow us on Facebook and Twitter!
Another local official said tensions have been high after Tuareg tribesmen were expelled by other residents of Ghadames.
The official said residents "set fire to two houses and four vehicles" in a predominantly Tuareg neighbourhood following the day's unrest.
Ghadames, which is also known as the "Pearl of the Desert," is a UNESCO World Heritage Site and home to Roman ruins close to Libya's borders with Algeria and Tunisia.
The Tuareg have historically roamed over vast tracts of the southern Sahara and control smuggling routes criss-crossing the Sahel region.
A senior military official excluded the possibility of foreigners entering the country and stirring up the unrest.
"We are not aware of the entry of any external party," army spokesman Ali al-Sheikhi told AFP, pointing to regular air patrols over the area.
He added that a reconciliation committee had begun to reach out to the communities concerned in the hope of calming the situation.
The desert cities of southern Libya have been particularly vulnerable to tribal conflicts in recent months.
Ethnic tensions play into turf wars to control lucrative smuggling routes that cut across porous borders.
The latest violence comes as the country prepares to hold elections for a constituent assembly in June.