If you are a foreign citizen who is in the United States without permission, having overstayed the time permitted under your visa (as shown on your I-94), you can potentially cure the problem if you enter into a bona fide (real) marriage with a U.S. citizen and then apply for adjustment of status (a green card).
There are, however three cautions you should be aware of:
What type of visa did you use to enter the United States, and how long ago did you get that visa? If, for example, you got an F-1 student visa or H-1B worker visa several years ago and met your spouse while in the United States, you should be fine—no one is likely to accuse you of misusing the visa for a purpose other than its intended one.
But what if, for example, you have been dating your new spouse for quite some time, and a few months ago picked up a B-1 visitor (tourist) visa, bought a wedding ring, and then arrived in the U.S. in order to get married and apply for a green card? That, according to the immigration authorities, would be a misuse of the tourist visa. You weren't planning to be a mere tourist, you were planning to immigrate to the United States. You could be denied the green card on that basis, though there is a waiver you can potentially apply for. Talk to an attorney for a full evaluation of your case, and about the possibilities of applying for a waiver.
A foreign citizen who entered the United States with official permission (on a visa, visa waiver, or something similar), and who then marries a U.S. citizen, may file for a green card using the procedure known as adjustment of status, based on being an immediate relative of a U.S. citizen.
It doesn't matter, in this case, that you overstayed the time permitted on your I-94. If you can manage to avoid getting picked up by U.S. immigration authorities until the day you submit your adjustment of status application, then your subsequent stay in the United States will be lawful, and you'll be able to get your green card here (unless there are other problems with your application or eligibility).
Note that a foreign citizen who entered the U.S. illegally, however, is not usually permitted to file for adjustment of status.
What's so special about adjusting status? It protects you from the three- and ten-year inadmissibility bars that are applied to people who have stayed in the U.S. unlawfully for 180 days or more and who then left. Only departure from the U.S. and attempted return triggers this bar.
If you were to leave the U.S. after an unlawful stay of 180 days or more, and then attempt to apply for your green card through a U.S. consulate, the consular officer who interviews you about your application might ask to see proof of your location after the time your U.S. permitted stay ran out. For details on this process, see What Happens During Consular Processing?
If the consulate becomes aware of your unlawful stay in the United States, you could possibly apply for a waiver (legal forgiveness), but you'd have to show that refusing to admit you as a U.S. resident would result in extreme hardship to your U.S. citizen or lawfully resident spouse or parent. In order to prove extreme hardship, you must provide evidence of hardship with respect to factors such as health, finances, education, personal considerations, and the like. This can be difficult to prove.
There's a major exception to the rule allowing immediate relatives of U.S. citizens who entered the U.S. legally to apply to adjust status in the United States. It doesn't work if your entry was on a K-1 fianc é visa, but you didn't marry the fianc é who petitioned you.
Marriage to a different U.S. citizen might still allow you to get a green card someday, but you will have to leave the U.S. first. The citizen will then have to file an I-130 petition on your behalf, and you'll need to do your application and interview through a U.S. consulate in your home country. Watch out for the inadmissibility bars if you stayed unlawfully in the U.S. for six months or more.
An experienced immigration attorney can help you confirm your eligibility to adjust status, prepare the paperwork, and otherwise advise you on the best strategy for obtaining a U.S. green card.