Updated

Rebels from the western town of Zintan were seen as heroes after playing a key role in toppling Moammar Gadhafi. Empowered and flush with weapons from Libya's civil war, the militiamen now are fighting again — settling scores with a rival tribe in clashes that have killed dozens of people.

The bloodshed last month between the rebels and the Mashashia tribe reflects the simmering divisions left over from Gadhafi's practice of consolidating his power by pitting communities against each other.

Some fear that transition to democracy in this oil-rich North African nation — already suffering after the civil war that led to Gadhafi's downfall in 2011 — will be further derailed.

That transition began July 7 with Libya's first parliamentary elections in a half-century. The new legislature will appoint a government that faces a web of unsettled conflicts in a society left crippled and wounded by four decades of repression, simmering ethnic hatred and no real judicial system under Gadhafi.

Many Libyans identify with their own tribe, their city or their regional affiliation. With a relatively small population of about 6 million people, residents can easily recognize each other by their dialect, the way they dress and sometimes even their facial features.

Libya's unresolved conflicts include:

— The third-largest city of Misrata and the rival Tawargha tribe. Militiamen in Misrata expelled about 40,000 tribesmen, accusing them of killing and raping civilians in Misrata as Gadhafi's forces besieged the coastal town on the Mediterranean in the spring of 2011.

— Misrata and the town of Bani Walid. The smaller town, a Gadhafi stronghold, was the last to fall to the rebels and is home to Libya's largest tribe, the Warfala.

— The city of Zawiya, where militias have clashed with the Warshfana tribe.

— The town of Zawara, populated by ethnic Berbers, which faced off with the Arab towns of Joumail and Ragdaleen.

— The Arab Zwia tribe and the Tabu, a tribe of African origin, long suppressed under Gadhafi. They are fighting in southern Libya, near the border with Chad.

While Gadhafi's policies brought lots of unrest between tribes and communities, residents say the divisions ran deeper during the days of Ottoman rule and later under Italian colonizers in the 20th century.

This month's election suggests a possible victory of an alliance led by Mahmoud Jibril, a senior official under Gadhafi until he joined the rebels in the 2011 uprising and became prime minister of the provisional government. His critics warn that national reconciliation and transitional justice might become distorted because of Jibril's ties to his Warfala tribe, which has allies in Zintan but is hated in Misrata.

"There is a pileup of injustice. The whole nation fought against each other, and for 42 years faced injustice," said longtime anti-Gadhafi opposition leader Mohammed al-Megarif, who is also head of the National Front party.

"This is what we got from Gadhafi — a desire to take revenge, because after a long series of crimes against his people, he didn't give people a chance to forgive."

El-Magarif said Gadhafi turned tribes against each other, and sometimes even encouraged divisions within the same tribe by giving jobs and wealth to low-ranking members while alienating the top leaders.

"Bribery was the easiest thing to do," he said.

Origins of tribal conflict, in some instances, can date to before the Gadhafi era.

Sheik Ali al-Zaytouni of the Mashashia tribe said that for hundreds of years, his people and residents of Zintan were shepherds who vied for grazing lands.

"We inherited the antagonism," al-Zaytouni said.

When Gadhafi came to power, "he knew how to spark tension between us. He discriminated against us while he pampered Zintan," he said, adding that no top state officials ever were drawn from the Mashashia tribe.

Khaled al-Zintani, a spokesman of the Zintan council, said Gadhafi moved the Mashashia tribe to areas close to Zintan in 1970s to put pressure on the town.

"He knew that Zintanis are people of resistance. ... The tyrant needed to find a way to create tension in Zintan," al-Zintani said.

Al-Zaytouni denied that his tribe helped Gadhafi's forces attack Zintan and other western mountain towns in the uprising.

"We were neutral. We didn't have weapons, and we knew if we rise up, Gadhafi would wipe us from the map," he added.

However, al-Zintani accused the Mashashia of helping Gadhafi's forces by offering their knowledge of the terrain.

Zintan was a de facto training camp for anti-Gadhafi fighters from across Libya's regions and tribes in the weeks before the rebels pushed into Tripoli in August 2011.

Now, there are tanks parked in a wooded area of the town. A municipal building has been turned into a weapons warehouse, storing Katyusha rocket launchers, anti-aircraft guns and tons of ammunition. Houses have become prisons, including one that holds Libya's most important inmate — Gadhafi's son and onetime heir apparent, Seif al-Islam — as well as members of the dictator's forces captured in the fighting.

Fighting in June left about 100 people dead after the Mashashia refused to hand over 10 men wanted for questioning in the killing of a top Zintan commander, al-Zintani said.

The siege of the city of Misrata by Gadhafi's forces during the first months of the uprising has left another painful legacy of hatred.

Misrata was one of the Libyan cities that suffered the most in the uprising. Gadhafi sent artillery and tanks to bombard the city and used snipers on rooftops to pick off those who fought back. Hundreds were killed and thousands were injured.

Women were raped, and video showing the assaults was found on cell phones of detained Tawergha fighters.

Accused of collaborating with the government troops, members of the Tawergha tribe fled their hometown about 20 miles south of the coastal city and took shelter in several places, including a military academy in Janzour, near Tripoli.

Displaced Tawergha men and women now pack the small rooms that once housed students. They occasionally hear that a member of their tribe is abducted outside the compound and brought to Misrata to face retribution.

Mabrouka Massid, a 46-year-old housewife, sat cross-legged in a small room with mattresses spread on the floor where her family of eight has been living since August 2011.

"Bullets rained over our house, so we fled — some in cars, others on foot. Some of us took days walking on foot trying to find a safe area," Massid said.

She acknowledged that some Tawergha men helped Gadhafi's forces besiege Misrata.

"Our youth were fooled," she said. "Gadhafi told them Americans are coming to invade the city."

Another refugee, 28-year-old Sadina Ahmed, was more frank: "Our guilt is that we loved Moammar because he gave us a good life, and we lived well."

An elderly woman interrupted, saying the Tawergha tribe also suffered during the siege.

"For months, we couldn't tell night from day. The shelling was not only on Misrata but also on us," she said. "What they say about killing their men and raping their women are sheer lies, fear God."