My girlfriend is from Mexico, and I'm 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 legal across the U.S., 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 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 U.S. 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 probably won't be allowed to stay in the U.S. to apply for it, although she can still apply for it at a U.S. consulate in Mexico. But before leaving the U.S., 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. You're 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.