Masked gunmen stormed the headquarters of Libya's state oil firm in Tripoli on Monday, killing two members of staff before security forces repelled the attack.
At least 10 people were wounded in the assault on the National Oil Corporation's offices, which was the first of its kind for the company.
Security forces rescued NOC chairman Mustafa Sanallah and other staff from the landmark building in the centre of the Libyan capital, the upper windows of which were damaged from explosions.
"The building was heavily damaged due to the fire. Smoke is everywhere," Mr Sanallah said. "The gunmen attacked the lower floors with random shooting and explosions. It's a very violent attack."
One of the attackers was killed by the security forces. The rest blew themselves up.
"Three or five gunmen were shooting inside the building," a NOC employee told Reuters, after he fled through an open window. "Several people were shot."
The building is covered in glass and several people were injured by shattered windows, which one witness said were broken by security forces to allow people to escape.
Firefighters used a crane to rescue a group of employees trapped on the roof, The Libya Observer reported.
Surrounding roads were cordoned off as ambulances took casualties from the building before the security forces counter-attacked.
No group has yet claimed responsibility for the attack, but the Tripoli security chief Salah Al Semoui blamed ISIS.
The UN Support Mission in Libya (UNSMIL) denounced Monday's "cowardly terrorist attack", calling it a "blow against Libyans everywhere".
The UN mission urged Libyans "to desist from futile side conflicts and come together, in partnership with the international community, to eradicate the scourge of terrorism across the country".
Monday's incident came less than a week after a fragile truce halted clashes between armed groups in Tripoli. At least 63 people were killed in the fighting between August 27 and September 4.
Libya has been divided between rival governments and military factions based in the east and west of the country since 2014, causing political deadlock and an economic crisis.
However, the NOC continued to function relatively normally across Libya, which relies on oil exports for most of its income.
Despite production being hit by blockades and attacks on oil facilities, last year output partially recovered to around one million barrels per day.
Last week, the NOC announced plans aimed at boosting oil revenues by 80 per cent to $23bn (Dh84.4bn), compared with $13bn in 2017. Despite disruptions this year, its revenues from the start of the year to the end of July reached $13.6bn.
Tripoli was shaken by clashes between armed groups earlier this month but the capital has also seen occasional militant attacks.
In May, ISIS claimed a deadly assault on the national election commission's offices in which 14 people were killed. The group also claimed an attack in 2015 on the Corinthia Hotel, another Tripoli landmark.
Libyan commander Khalifa Haftar calls Italians 'enemies'
Tripoli militias reach ceasefire agreement
Salvini slams French interference in Libya as Tripoli fighting rages