Officers stripped down the BMW sedan after noticing it was being driven by two young men they suspected of being people smugglers.
Police said on Thursday that during their search they detected a heart beating.
They "carried out an exhaustive search and found a false compartment inside the dashboard," from where the 19-year-old Guinean migrant emerged "in a very bad physical state," police said.
They said the teenager was hospitalised.
The two suspected smugglers fled the scene. But one of them, a Spaniard aged 23, was later arrested and charged with people trafficking.
Spain's other North African enclave, Ceuta, was the scene of another bizarre clandestine attempt to enter the EU state when an eight-year-old boy from the Ivory Coast was found in a suitcase.
Spanish media reported the child's father, already living in Spain, had paid a young woman to carry the case through border control.
Melilla has for some years been a flashpoint for African migrants trying to enter Spain, with authorities stepping up security by strengthening border barriers after thousands of immigrants tried to scale existing fencing in 2005.
Each year, thousands of Africans seek to cross into Melilla and Ceuta as the only land borders between Africa and the European Union.