The immigration process can be initiated outside the US. Commonly referred to as Consular Processing, you can apply for a visa at the US Consulate in your country. Persons already in the US on a valid legal status can adjust their status to permanent residency (green card) by filing Form I-485 with the USCIS.
You can apply for a immigrant or non immigrant visa depending on the purpose of your visit. Applying for a immigrant visa will qualify you for a green card through which you can work and live in the US permanently. I f you travel is for a temporary period, you can apply for a non immigrant visa. The US Consulate takes care of the immigration process when you are outside the US. Once your petition is approved and you get the desired visa, you can enter the US. Your green card will be mailed to you.
Your US citizen or permanent resident spouse would have applied on your behalf with the USCIS in the US. The USCIS, will review it and on approval, send the approved petition to the National Visa Center (NVC) for the next level of processing. The NVC, on its part will send you a package that will have forms, list of supporting document to be submitted and other instructions. Once the application process is complete, and once visa numbers becomes current for your category for your country of birth, you will receive a notification about your appointment and the notification will include additional forms and instructions.
It is mandatory you attend a personal interview. Your dependent family members who qualify to accompany you to the US are also required to attend an interview at the consular post. Remember that the Consulate will schedule appointments for the interview on short notice. So be prepared to travel when the appointment is scheduled. Apart from these requirements, you have to take a medical examination with a physician approved by the US consular post.
Whether it is Consular processing or adjustment of status, applicants have to submit a few supporting documents. Both are more or less similar barring a few exceptions. When you take the Consular processing route, you are required to submit a police certificate of good conduct from each country in which you, or your family member resided for six months or more from the time you turned 16 years old. In addition, you are required to submit evidence for having fulfilled any obligatory military service.
As far as the processing time is concerned, when compared with the adjustment of status process, Consular processing takes lesser time and can take as little as six months to complete. Though it is quicker, but because the process is carried out outside the US, should there be any issue with the application, you will have to stay back until the problem is fixed. Also remember that you do not have a formal appeal process while dealing with consular processing applications as there is for Adjustment of Status applications. Also make sure you are in legal immigrant status while the application for an immigrant visa is pending.