The invention provides cement mortar and a preparation method thereof, and relates to the technical field of building materials. The cement mortar comprises the following components in percentage by weight: 10-20% of ordinary Portland cement, 10-15% of fly ash, 40-60% of quartz sand, 5-10% of a water reducing agent, 5-15% of a thickening agent, 4-8% of a retarder and the balance of water. The titanium gypsum is adopted as the retarder, on one hand, the resource utilization of the titanium gypsum is improved; and on the other hand, the titanium gypsum prepared through the preparation method of the titanium gypsum is good in retarding effect, by controlling the mass ratio of the retarder to the thickening agent, the stability and the water retention capacity of the cement mortar are obviously improved, and the mortar material separation degree is low; and the mortar has better size shrinkage resistance and cracking resistance.