The simplest case is one where a US citizen marries a non-citizen who came into the country with permission. The citizen will need to file a family petition for their spouse and then prove the validity of their marriage. The green card application can be submitted at the very same time. This process, from beginning to end, generally takes between 3 and 4 years.
If one entry was effected without permission then a step is added which waives the unlawful entry but only if extreme hardship to the spouse can be established. This decision usually takes over a year, on top of the 3 to 4 standard process, and necessitates the immigrant leaving the country to end up with a green card.
When a U.S. citizen is married to a non-citizen and they are in their home country, the green card application needs to be processed through the U.S. embassy in that country and the interview scheduled there. This process only takes 1 to 2 years.
If instead of being married to a U.S. citizen, the immigrant is married to a legal permanent resident of the U.S., the process doesn't change except that they must wait for a visa to become available before they can apply.