Complex sentence: Typically a father, brother or husband (a "mahram") or paternal grandfather is wali mujbir, or if there is no Muslim relative, a qadi may function as wali.
Split into simpler sentences: Typically a father, brother or husband (a "mahram") is a wali. If there is no Muslim relative, a qadi may function as wali.