CF is caused by mutations in the CFTR gene, which encodes a protein responsible for regulating the movement of salt and water in and out of cells. When this protein is defective, it leads to the production of thick and sticky mucus, which can clog airways and ducts, particularly in the lungs and pancreas.