(Updates toll, details)
By Ayman al-Warfalli
BENGHAZI, Libya, Feb 5 (Reuters) - Clashes erupted in the centre of Libya's main eastern city Benghazi on Thursday as pro-government forces pushed to take the port district from Islamist militants, and seven soldiers were killed, witnesses and military officials said.
The fighting mirrors a wider struggle in the oil-producing North African state where two governments and parliaments, allied to rival armed groups, are vying for control almost four years after Muammar Gaddafi fell to an armed uprising.
Backed by forces led by General Khalifa Haftar, army special forces in mid-October launched an offensive against Islamists in Benghazi, expelling them from the airport area and from several camps the army had lost during the summer.
Army forces have since been trying to retake the port area and two other districts where pro-government forces say fighters from the militant Islamist Ansar al-Sharia group are holed up.
The port, the main gateway for food imports into eastern Libya, has had to close.
On Thursday morning, army vehicles advanced on the Corniche road towards the port gate and a nearby court building. Soldiers took over several government buildings such as a passport office, a state insurance and a state bank damaged in earlier fighting.
Around 25 soldiers were wounded, army sources said.
"The road to the port is under our control," said Faraj al-Barassi, a military commander.
Heavy gunfire continued until late at night. The court is famous as the place where the 2011 uprising against Gaddafi started with peaceful protests against his jailing of many opponents.
Army forces in eastern Libya are loyal to internationally recognised Prime Minister Abdullah al-Thinni, who was forced to leave the capital Tripoli in the west in August for the eastern city of Bayda when a group called Libya Dawn seized the capital.
The new rulers in Tripoli set up their own government and parliament, but these have not been recognized by the United Nations. Both sides have fought each other on several fronts.
Libya has failed to build up a national army and efficient state institutions since the end of Gaddafi's one-man rule, and the country is now effectively dominated by former rebel brigades who have carved out competing fiefs. (Writing by Ulf Laessing; Editing by Cynthia Osterman)