Consciousness or spirit does not arise from matter. It is just an equal principle that manifests within matter (the physical universe or the individual person).
When a person attains jīvanmukti (spiritual liberation while alive) he has essentially transcended the body (Prakṛti). After death, his puruṣa (personal spirit) remains as pure spirit without body, because Puruṣa is eternal.