If you have entered the United States without permission, or stayed here beyond the expiration date of an I-94 (given out after entry on a visa) or other permitted stay, then you are considered an "undocumented" (or in common language, "illegal") immigrant. Applying for asylum might still be an option for you, if you fear returning to your home country and do not have residency rights in any other country.
You would need to either submit an application on your own (an "affirmative" application), within certain time limits, or if you are caught by the immigration authorities, apply for asylum during your immigration court hearing.
The fact that you are in the U.S. illegally is no bar to applying for asylum—though it might cause you to be picked up by the immigration authorities, which would mean you'd have to skip the first, affirmative application step, such that the first hearing on your claim would be in immigration court (also called the "Executive Office for Immigration Review" or "EOIR").
In order to be granted asylum, the person must first be able to prove eligibility for refugee status. Very briefly summarized, this means that the person can prove having been persecuted, or that he or she likely will be persecuted in the future, by either the government of his or her home country or by a group beyond the government's control.
Examples of persecution include torture, discrimination, threats of injury or death, or imprisonment.
In addition, the persecution must be on account of one of five grounds: either the person's race, nationality, religion, political opinion, or participation in a particular social group. That means, for example, that if the local police chief harassed you because you're dating his daughter and he disapproves, you would not qualify for asylum, because his reasoning is personal, with no connection or "nexus" to one of the five grounds.
For more about eligibility for asylum, see Who Is Eligible for Asylum or Refugee Protection in The U.S.?
To apply for asylum, you must submit Form I-589, Application for Asylum and Withholding of Removal, issued by U.S. Citizenship and Immigration Services (USCIS). Along with the form, you must submit documents, affidavits, and any evidence you have proving who you are and what persecution you (and your family, if any) faced in the past or would face in the future in your home country.
Even if you don't have many documents of your own, you should add documents created by others that are relevant, such as human rights reports and newspaper articles proving that your experience is similar to that faced by other people in your country.
There's a time limit: you must file all the necessary documentation within one year of entrance to the United States or of the expiration of your permitted U.S. stay.
The instructions that come with Form I-589 tell you what to do from a procedural standpoint. However, you'd be well advised to get an attorney's help with this process. Proving that you truly fit the grounds for eligibility, and aren't just making up a story, requires a lot of preparation and effort.
It's not uncommon for attorneys to submit a packet of materials that is at least one inch thick, and to help the client write a summary of his or her story that is several pages long.
Within 60 days of receiving your application, USCIS tries to conduct an interview to review your application and hear your personal testimony. Lately, however, the agency has been extremely backlogged, so whether your case is heard this soon depends on its current policy regarding which applications to deal with first, as well as its staffing levels.
You will not receive the decision the day of your interview, but will be asked to return at a later day to find out whether your request for asylum was granted. If granted, you will receive evidence of your approved status, and will be able to apply for a work permit, then for a green card in one year.
If your case is not approved, you will be referred to removal (deportation) proceedings, which will begin in just a few weeks.
As we've already mentioned, if you are seeking asylum status, it is a good idea to consult with an experienced immigration attorney. Your attorney can help you gather evidence and prepare for the asylum interview, thus increasing your chances of being successful the first time around. And if your case has been referred to immigration court, you definitely want a lawyer's help.