This paper aims to analyze the link between environmental degradation and institutional quality and the price of oil moderated by economic complexity and the underground economy. We use quantile regressions with annual panel data for 15 countries in the Middle East and North Africa during 1995-2021. The findings indicate that institutional quality, economic complexity, and output positively and heterogeneously impact environmental degradation. However, the square of production has a negative impact, confirming an inverted U relationship between production and environmental degradation. Likewise, we find that the price of oil and the underground economy have a negative and heterogeneous impact on environmental degradation. Based on our results, a potential recommendation for policymakers is that the institutional framework of Middle Eastern and North African countries should be accompanied by a more significant concern for the environment instead of prioritizing extractive growth that is detrimental to the environment's environmental sustainability. Likewise, economic diversification will mitigate environmental degradation and improve formal employment. Our findings are relevant to policymakers and researchers interested in promoting ecological sustainability.