A pneumothorax occurs when air fills the space between your lung and chest wall. This can cause all or part of your lung to collapse. The main cause of a pneumothorax is an injury to the chest cavity that punctures the lungs.