Many US citizens get married to foreign nationals who are undocumented, i.e. not legally in the United States. The US citizens wonder if they can "sponsor" their spouse to get lawful status. The answer depends on various facts, so it is important to review the specific details of your case with an experienced immigration attorney.
In general, if you entered the US legally and overstayed your authorized stay, your US citizen spouse can petition for you to become a permanent resident. All the usual requirements to become a permanent resident must be met, including showing good moral character, completing a medical exam, providing an Affidavit of Support, etc. (see blog posts and website links below). However, if you entered using the Visa Waiver Program (VWP), you should file for permanent residence before the 90-day period of authorized stay ends.
If you entered the US without inspection, you will have a harder time getting permanent residence. You cannot complete the process in the US because you are ineligible for Adjustment of Status. You need to apply at a consulate in your home country. Your spouse will need to request a waiver of inadmissibility on Form I-601. Your spouse needs to show that it would cause "extreme hardship" if you were not allowed back to the US. "Extreme hardship" is a very high standard - it needs to be greater than the normal hardship that a person would endure if they were separated from their spouse involuntarily. This includes showing why your spouse could not move to your country to live with you there.
If you entered without inspection over one year ago, OR were ordered removed from the US AND attempted to enter again without inspection, there is no waiver until you have been outside the US for 10 years.
If you are an undocumented immigrant married to a US citizen, please contact an immigration lawyer about your case. Do not attempt to file the paperwork yourself, especially if you entered without inspection (EWI), because there are many facts to analyze. The date that you entered, any prior immigration paperwork that was filed for you, your criminal history, and many other factors are important. Also note that the waiver process can take months or even years before you get a decision.
Blog on marriage-based filing