My girlfriend is from Mexico, and I am a U.S. citizen. She, however, has no status in the United States, having crossed the border illegally when she was in her early twenties. If we get married, can I help her become a U.S. citizen on that basis?
Your question has several important legal aspects, which we'll try to address separately here.
First, the matter of same-sex marriage and U.S. immigration benefits: Yes, they exist, ever since the U.S. Supreme Court's Windsor decision removed the bar to immigration rights for same-sex couples. The spouse of a U.S. citizen is an "immediate relative" in immigration law lingo, and therefore immediately eligible to apply for U.S. lawful permanent residence (a green card).
The important thing in petitioning for a same-sex spouse will be to make sure that the marriage is legal in the state and country where it takes place. If you marry in the United States, you'll need to make sure to follow any state laws (such as prohibiting marriage between close relatives or where one party is underage). However, same-sex marriage is currently legal across the United States, owing to a Supreme Court decision called Obergefell v. Hodges.
Be sure to obtain a certified copy of your marriage certificate before moving forward with the immigration process.
Next, the matter of what rights a same-sex spouse, or any spouse of a U.S. citizen, gains: It's too soon to talk about U.S. citizenship. After a successful application, you will first be approved for a U.S. green card, or lawful residence.
Also be aware that, with a marriage less than two years old at the time you submit the visa petition (Form I-130) to start the application process, your spouse will gain "lawful conditional residence" as opposed to "lawful permanent residence," and have to submit another application (Form I-751) before the end of a two-year period to remove the conditions and become a full-fledged permanent resident. After three years of marriage and living with a U.S. citizen, a green card holder can apply for naturalized U.S. citizenship.
Now, to the most difficult part of your question: your girlfriend's undocumented status. Because she entered illegally, and assuming she has been in the United States for more than six months, she's likely got an inadmissibility problem, as described in Consequences of Unlawful Presence in the U.S.--Three- and Ten-Year Time Bars.
That means that, although technically eligible for the green card, she might not be allowed to stay in the United States to apply for it (subject to the exception described below), although she can still apply for it at a U.S. consulate in Mexico. But before leaving the United States, she'd want to apply for what's called a "provisional waiver," if she qualifies for one. Leaving the United States without it could risk being prohibited from return for three or ten years. And the waiver needs to be based on extreme hardship to her U.S. permanent resident or U.S. citizen spouse (that's you) and/or parents. See the Inadmissibility and Waivers section of Nolo's website for details.
Now, for the exception: In June of 2024, the Biden Administration issued an Executive Order to help undocumented spouses who are in the situation described above. It allows people married to U.S. citizens who have lived in the United States for 10 or more years before June 17, 2024 and who are legally married to a U.S. citizen to apply for a green card entirely within the United States, thus avoiding the inadmissibility problem described above. The program is called "Parole in Place," and essentially converts their unlawful U.S. entry into a lawful one. They will also be eligible for work authorization for up to three years.
However, specific application procedures have not yet been announced (though the program is due to begin in mid-August of 2024), and legal challenges are expected. See the USCIS web page on Process to Promote the Unity and Stability of Families for the latest information.
You are in a situation where there might be no risk-free option available for your new spouse's application for U.S. immigration benefits, which you would be best off discussing with an experienced immigration attorney.