A West African migrant entered the Spanish territory of Ceuta from Morocco curled up next to a car engine and another was hidden behind the back seat of the Mercedes-300 car.
Spanish police found the pair late on Sunday during a customs check at El Tarajal, near the Moroccan border.
The two men from Guinea got first aid, having suffered from a lack of oxygen, Spain’s Guardia Civil police said.
Sub-Saharan Africans often try to enter Ceuta, as a gateway to the EU.
The Mercedes 300 was found to have false number plates. Police detained two Moroccan men who were in the car when it was stopped.
It is not clear how long the man in the engine compartment had been inhaling noxious fumes for.