Marriage in Islam is a sacred contract that must fulfill specific pillars and conditions to achieve legal validity according to both Islamic and state law. One of the essential elements in a marriage contract is the presence of a marriage guardian (wali). In certain situations, the biological guardian (wali nasab) cannot perform his duty, requiring the appointment of a judge guardian (wali hakim). This study aims to analyze the role of the Head of the Office of Religious Affairs (KUA) as wali hakim in ensuring the legality of marriage contracts in Kebakkramat District, Karanganyar Regency, in 2025. The study employed a descriptive qualitative approach with field research methods. Data were collected through interviews, observations, and documentation. Research informants consisted of the Head of KUA, marriage registrars, married couples, and community leaders. Data analysis used the Miles and Huberman model through data reduction, data display, and conclusion drawing. The findings reveal that the Head of KUA has a strategic role in ensuring the legality of marriage contracts through administrative examination, verification of guardian requirements, determination of wali hakim, and supervision of marriage implementation according to Islamic law and the Compilation of Islamic Law. The obstacles faced include limited public understanding regarding wali hakim, incomplete administrative requirements, and marriages conducted without official procedures. The efforts undertaken include marriage law socialization, premarital guidance, and strengthening coordination with village authorities and religious leaders. This study confirms that optimizing the role of the Head of KUA as wali hakim is essential in maintaining the legality and validity of marriage contracts within society.