Police said it appears that two other men who were able to get out of the boat died while trying to swim to shore in the Costa Teguise area.
The migrants were of North African origin, Spanish authorities said, and 18 survivors who made it to shore are being treated for hypothermia.
The cause of death for the five in the boat could not be confirmed, but police said it is probable that they drowned or died from hypothermia.
A spokesman for the Guardia Civil police force told AFP that three of those who died “could be minors”.
The boat arrived at the island at about 13:00 local time (12:00 GMT), he said.
Lanzarote is part of the Canary Islands archipelago and is about 130 kilometres (81 miles) from the Moroccan coast.