A commonly circulating rumor says that if an undocumented immigrant has been in the United States for at least ten years, they can get a green card. The next questions that typically arise are, "Is that true?" and "Where and how do I apply?"
This rumor has a grain of truth in it, but unfortunately there is no simple way to apply for U.S. lawful permanent residence (commonly known as a green card) based on length of time in the United States. We'll discuss the details here.
There is a remedy called "Cancellation of Removal," formerly called "Suspension of Deportation," which allows noncitizens who are already in Immigration Court proceedings, fighting against removal (deportation) from the U.S., to request relief if they have been in the U.S. for ten years or longer.
If approved, the Immigration Judge will grant the person a green card. But you have to be in court proceedings first, before applying for this. What's more, the ten years of living in the U.S. (being "continuously physically present" here) is not the only requirement.
You would also need to show that your removal from the U.S. would cause "exceptional and extremely unusual hardship" to one or more of your close family members—an even higher standard to meet than the "extreme hardship" required for many types of waiver applications. And, they must be U.S. citizens or lawful permanent residents (LPRs). The relatives who qualify include your spouse, parent, or child.
In addition, you need to show that you have "good moral character" and that you have not been convicted of certain crimes or violated certain laws.
Even after all that, you would need to convince the immigration judge that you deserve cancellation of removal according to the judge's subjective discretion.
As you can see, the standards for this form of relief are high. It's certainly not something you want to rush out and attempt to get picked up by the immigration authorities in order to apply for, unless you have sat down with a lawyer and determined that you have a strong case and are willing to accept the risks of receiving an order of removal.
Also beware of strategies like submitting another type of application to USCIS, such as for asylum, on the theory that it will probably be denied and thus get you into removal proceedings. In the asylum example, unless you meet the basic eligibility criteria for this remedy (you have a genuine fear of persecution in your home country), you risk being found to have submitted a "frivolous" case just to gain other immigration benefits. This carries legal consequences, namely a permanent ban from any U.S. immigration benefit.
Or let's say you tried submitting an application for a marriage-based green card based on a fake marriage. Such marriage fraud could lead to a finding that you lack good moral character, which would make you ineligible for cancellation of removal and lead to criminal prosecution.
For more information on this defense, see Green Card Through Cancellation of Removal (Non-LPR): Who Qualifies?. And for other ways that someone can qualify for a green card or temporary status in the U.S., see Noncitizens Seeking Visas, Asylum, and Green Cards.
It might also be worth consulting with an experienced immigration attorney, to see whether cancellation of removal is a remedy that would be available to you if you landed in deportation proceedings, or whether there's some other immigration benefit you could apply for.