Colonel Ayoub Qassem, quoted by a news agency operated by Libya's unrecognised authorities in Tripoli, said the rescue took place six nautical miles off Sabratha, 70 kilometres west of the capital.
He said 187 migrants were rescued from the blazing vessel and another boat nearby, 43 of whom were hospitalised with burns. Four South Africans had been burnt to death.
An investigation has been opened into the cause of the fire, said Qassem.
The migrants were to be handed over to anti-illegal immigration authorities in Zawia, which lies between Sabratha and Tripoli.
Also Read
Yesterday, Italy's coastguard said more than 2,400 migrants and three corpses had been recovered from people smugglers' boats off Libya in the previous 24 hours.
The figures signal a pick-up in the flow of migrants attempting to reach Italy via Libya, a route through which around 330,000 people have made it to Europe since the start of 2014.