Piglets may experience a variety of stress injuries, but the molecular regulatory mechanisms underlying these injuries are not well understood. In this study, we analysed the ileum of Large White (LW) and Mashen (MS) piglets at different times of starvation using chemical staining and transcriptome analysis. The intestinal barrier of piglets was damaged after starvation stress, but the intestinal antistress ability of MS piglets was stronger than LW piglets. A total of 8021 differentially expressed genes (DEGs) were identified in two breeds. Interestingly, the immune capacity (CHUK, TLR3) of MS piglets increased significantly after short-term starvation stress, while energy metabolism (NAGS, PLA2G12B, AGCG8) was predominant in LW piglets. After long-term starvation stress, the level of energy metabolism (PLIN5, PLA2G12B) was significantly increased in MS piglets. The expression of immune (HLA-DQB1, IGHG4, COL3A1, CD28, LAT) and disease (HSPA1B, MINPPI, ADH1C, GAL3ST1) related genes were significantly increased in two breeds of piglets. These results suggest that short-term stress mainly enhances immunity and energy metabolism in piglets, while long-term starvation produces greater stress on piglets, making it difficult for them to compensate for the damage to their bodies through self-regulation. This information can help improve the stress resistance of piglets through molecular breeding.