A commonly circulating rumor says that if an undocumented immigrant has been in the United States for at least 10 years, they can get a green card. The next questions that typically arise are, "Is that true?" and "Where and how do I apply for this 10-year green card?"
This rumor has a grain of truth in it, but unfortunately there is no simple way to apply for U.S. lawful permanent residence based on any length of time in the United States. We'll discuss the details of the remedy known as "non-LPR cancellation of removal" 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 United States, to request relief if they have been in the United States for 10 years or longer. If approved, the Immigration Judge will grant the person the right to a green card.
But you have to be in immigration court proceedings first, before you can apply for this. What's more, the 10 years of living in the United States (being "continuously physically present" here) is not the only requirement.
You would also need to show that your removal from the United States 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 immigration 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. (Then again, knowing this remedy is a possibility might give you comfort if you're worried about being picked up in an immigration raid.)
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 (that is, 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 the eligibility and mode of applying for this immigration defense, see Green Card Through Cancellation of Removal (Non-LPR): Who Qualifies?. And for other ways that a foreign national can qualify for a green card or temporary status in the United States, 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, either now or if you find yourself defending against deportation.