As population aging becomes the new demographic norm in China, its workforce structure is changing, and its demographic dividend is about to disappear. Artificial intelligence (AI) has been experiencing rapid progress in the last few years, and it is becoming an important tool to address the impact and challenges of an aging population. Therefore, this research introduces population aging and artificial intelligence into agricultural production, focusing on the effects of population aging on food security and the function played by artificial intelligence in it. From an empirical study conducted based on provincial panel data, the following conclusions arise. First, population aging in rural China has not negatively impacted food security, so there is no need to be overly pessimistic about the inevitable aging of the rural population. Second, AI has a favorable moderating function on the effects of population aging on food security. Third, the moderating effect of AI is heterogeneous. Compared with other provinces, AI can play a strongly positive moderating effect in central and west regions and major grain-selling areas. Based on the above findings, this paper proposes targeted policy recommendations on protecting food security in the context of artificial intelligence and population aging.