Five soldiers were killed and 15 have been missing since the Islamic State fighters attacked the checkpoint outside the eastern town of Ajdabiya, near the oil port of Bregaattack, one military official said. Two more soldiers were killed when the government sent reinforcements. Five were wounded.
"Fighting is continuing some 100 kilometres outside Ajdabiya," one official said.
Islamic State claimed responsibility for the attack in a statement on social media, saying it had captured ammunition and military equipment.
Islamic State has exploited a growing security vacuum in Libya, where two governments and parliaments are fighting for control four years after the toppling of Muammar Gaddafi.
The official prime minister has been based in the east, working with his cabinet out of hotels, since the capital, Tripoli, was seized by a rival group that set up its own government.
Both sides command loose coalitions of former anti-Gaddafi rebels. After Gaddafi's ouster, the various factions split along political, regional and tribal lines.
Militants loyal to Islamic State, the group which has seized much of Syria and Iraq, has built up a large presence in Sirte, to the west of Ajdabiya.
Separately, India said on Friday that four of its nationals had been detained near Sirte, but that it had secured the release of two of them. The Indian government did not say who was behind the detention of the men but said it was in touch with the families concerned.
Get Breaking news, live coverage, and Latest News from India and around the world on NDTV.com. Catch all the Live TV action on NDTV 24x7 and NDTV India. Like us on Facebook or follow us on Twitter and Instagram for latest news and live news updates.