The compressive strength is an important mechanical feature of concrete that is needed in construction design. Thus, a lot of investigations were carried out to predict the compressive strength of various concretes. However, the prediction models for the compressive strength of cement mortar or paste that include magnetic water (MW) and granulated blast-furnace slag (GBFS) are still limited. The current study has developed hybrid algorithms based on adaptive neuro-fuzzy inference system (ANFIS) for modeling the compressive strength of cement mortar and paste that made with MW and GBFS as a novel mixture content. A total of 144 experimental sets of concrete-compressive strength tests for each cement mortar and paste were collected to train and validate the proposed methods, in which the cycles number of water magnetization, cement, GBFS, superplasticizer contents and curing time are set as the input data while the compressive strength value is set as the output. The developed hybrid algorithms of ANFIS optimized by firefly algorithm (FA), Improved Particle Swarm Optimization (IPSO) and biogeography-based optimization (BBO) algorithms for predicting the compressive strength of the mortar and paste. The proposed models and relevance vector machine (RVM) approach were evaluated and compared. The results showed that the ANFIS-FA outperforms other models for modeling the compressive strength of cement mortar and paste. The adjusted-coefficient of determination and root mean square error values of cement mortar models (96.20%, 92.33%, 92.36% and 89.41%) and (2.17 MPa, 3.10 MPa, 3.18 MPa and 3.06 MPa) and of cement paste models (96.92%, 80.91%, 92.19% and 88.18%) and (2.45 MPa, 5.80 MPa, 4.39 MPa and 5.20 MPa) were determined for ANFIS-FA, ANFIS-IPSO, ANFIS-BBO and RVM models, respectively, which indicate that the ANFIS-FA is a suitable model for estimating the compressive strength of cement mortar and paste that include MW. Moreover, the sensitivity of MW and GBFS is shown high for modeling the compressive strength of cement mortar.