In myriad areas of public life-from voting to professional licensure-the state collects, shares, and uses sex and gender data in complex algorithmic systems that mete out benefits, verify identity, and secure spaces. But in doing so, the state often erases transgender, nonbinary, and gender-nonconforming individuals, subjecting them to the harms of exclusion. These harms are not simply features of technology design, as others have ably written. This erasure and discrimination are the products of law. This Article demonstrates how the law, both on the books and on the ground, mandates, incentivizes, and fosters a particular kind of automated administrative state that binarizes gender data and harms gender-nonconforming individuals as a result. It traces the law's critical role in creating pathways for binary gender data, from legal mandates to official forms, through their sharing via intergovernmental agreements, and finally to their use in automated systems procured by agencies and legitimized by procedural privacy law compliance. At each point, the law mandates and fosters automated governance that prioritizes efficiency rather than inclusivity, thereby erasing gender-diverse populations and causing dignitary, expressive, and practical harms. In making this argument, the Article challenges the conventional account in the legal literature of automated governance as devoid of discretion, as reliant on technical expertise, and as the result of law stepping out of the way. It concludes with principles for reforming the state's approach to sex and gender data from the ground up, focusing on privacy law principles of necessity, inclusivity, and antisubordination.