This research addresses the environmental challenges associated with traditional masonry blocks, which rely heavily on cement and river sand, leading to resource depletion and ecological degradation. Alkali-activated masonry blocks represent a promising alternative, utilizing sustainable materials to reduce carbon emissions and promote resource efficiency. This study investigates the potential of predicting the compressive strength of geopolymer mortar made from supplementary cementitious materials, such as eggshell ash and rice husk ash, alongside quarry waste, as viable replacements for conventional raw materials. The eggshell ash and rice husk ash are rich in calcium and silica, and both react with alkaline activators and are essential in producing a gel-like binder. These materials enhance the blocks’ mechanical properties and contribute to waste reduction and resource efficiency. Through experimental testing, 27 distinct mix designs were developed and evaluated, resulting in the testing of 189 mortar cubes for compressive strength. Six machine learning techniques, namely artificial neural networks, boosted decision trees, K-Nearest Neighbors, random forest regression, support vector regression, and XGBoost, were employed to predict compressive strength. The results revealed that XGBoost outperformed all other methods, achieving a training dataset accuracy of 97.6% and a testing dataset accuracy of 95.2% for dry conditions while also attaining a predictive accuracy of 91.8% and 85.7% for wet conditions. Notably, XGBoost demonstrated a coefficient of determination (R²) of 0.958 for dry conditions and 0.938 for wet conditions, indicating its precision in predicting compressive strength. Furthermore, the analysis of feature contributions highlighted that NaOH content played a critical role in strength predictions, underscoring the potential of machine learning, particularly XGBoost, as a transformative tool for optimizing geopolymer mortar formulations sustainably and effectively. By leveraging recycled materials like ESA and RHA, this study contributes to developing stronger, more reliable masonry blocks, reducing reliance on traditional resources and promoting sustainable construction practices.