Recombination-activating genes (RAGs) play a crucial role in the V(D)J recombination process and the development of immune cells. The development of the immune system and its mechanisms in pigs exhibit greater similarity to those of humans compared to other animals, thus rendering pigs a valuable tool for biomedical research. In this study, we utilized CRISPR/Cas9 gene editing and somatic cell nuclear transfer technology to generate RAG2 knockout (KO) pigs. Furthermore, we evaluated the impact of RAG2 KO on the immune organs and immune cell development through morphological observations, blood analysis and flow cytometry technology. RAG2 KO cell lines were used as donors for cloning. The reconstructed embryos were transplanted into 4 surrogate sows, and after 116 days of gestation, 2 sows gave birth to 12 live piglets, all of which were confirmed to be RAG2 KO. The thymus and spleen sizes of RAG2 KO pigs were significantly smaller than those of wild-type (WT) pigs. Hematoxylin-eosin staining results revealed that the thymus and spleen tissue structures of RAG2 KO pigs were disorganized and lacked the characteristic structures, indicating that RAG2 KO leads to dysplasia of the thymus and spleen. Hematological analysis demonstrated that the total number of white blood cells and lymphocytes in the circulation of RAG2 KO pigs was significantly lower, while the number of eosinophils was higher. Flow cytometry results indicated that the proportions of mature T and B lymphocytes were significantly reduced compared to WT pigs. These findings successfully verified the immunodeficiency phenotype of RAG2 KO pigs. This study may provide experimental animals for the development of tumor models and humanized animals.