In response to increasingly stringent global environmental policies, this study addresses the pressing need for accurate prediction models of CO2 emissions from vehicles powered by alternative fuels, such as compressed natural gas (CNG). Through experimentation and modelling, one of the pioneering CO2 emission models specifically designed for CNG-powered vehicles is presented. Using data from chassis dynamometer tests and road assessments conducted with a portable emission measurement system (PEMS), the study employs the XGBoost technique within the Optuna Python programming language framework. The validation of the models produced impressive results, with R2 values of 0.9 and 0.7 and RMSE values of 0.49 and 0.71 for chassis dynamometer and road test data, respectively. The robustness and precision of these models offer invaluable information to transportation decision-makers engaged in environmental analyses and policymaking for urban areas, facilitating informed strategies to mitigate vehicular emissions and foster sustainable transportation practices.