Climate change, which arises from the activities of humans, leads to increased temperature and irregular rainfall patterns, which pose a significant threat to food security, particularly in developing nations like Nigeria, where agriculture is critical to the economy and livelihood. Environmental degradation, exacerbated by climate change, further complicates this scenario by reducing arable land, depleting water resources, and altering weather patterns, all of which contribute to decreased agricultural productivity. The current study aims to assess the impacts of the dual challenges of climate change and environmental degradation on food security in Nigeria, using quarterly time series data from 1991 Q1 to 2023 Q4. The research employs multiple machine learning algorithms, including Multiple Linear Regression, K-Nearest Neighbor (K-NN), Support Vector Regression, and Random Forest, to model the complex relationships between climate variables (CO2 emissions, temperature anomalies) and food production index (FPI), a proxy for food security. The results indicated that CO2 emissions and temperature anomalies have a significant negative effect on agricultural productivity, while land use and fertilizer consumption positively influence food production. The study concluded that sustainable land management practices, climate-resilient agricultural methods, and investment in agricultural infrastructure are critical to mitigating the adverse effects of climate change on food security. Policy recommendations were made to enhance resilience in Nigeria’s agricultural sector.