Among those rescued were 63 people from sub-Saharan Africa, officials said without specifying their nationalities, and 29 Algerians.
Most of the migrants were taken to the port of Malaga in southern Spain, following a "complicated" rescue operation in rough seas around 49 nautical miles from the coast, a maritime rescue official told AFP.
The group included three women and a child as well as a boy who had to be hospitalised after suffering from hypothermia.
Authorities used a system that detects heartbeats to detect the migrants, said Irene Flores, a spokeswoman for the Melilla government.
More From This Section
The 22 were taken to a migrant centre in Melilla where they will be eligible to lodge a request for asylum. The lorry driver and his assistant were detained.
The Spanish interior ministry has said more than 11,600 migrants and refugees arrived in Ceuta and Melilla last year, the majority from Syria -- a 55 per cent increase from 2014.