You are free to marry anyone you choose, within the limits of your state's law. State laws sometimes forbid marriages of close relatives or under-age people, but so far do not forbid marriage to an undocumented (often called "illegal") immigrant. So you shouldn't need an attorney for this part of the process.
Whether you can obtain a green card for your immigrant spouse is, however, a more difficult question. We're going to start by assuming that you are a U.S. citizen (as opposed to a lawful permanent resident). The spouse of a U.S. citizen becomes an "immediate relative," in immigration law terminology, and therefore immediately eligible to apply for a green card.
But the process isn't as easy as it sounds. Much depends on how your immigrant spouse last entered the United States, and whether he or she by chance falls under some old immigration laws that make the procedural part of this process easier. It would indeed be worth seeing an attorney for a full analysis -- and for help with the forms and other required paperwork, which can themselves be overwhelming.
We'll give you an overview of the legal issues below, but please realize that we can't cover every detail or exception here.
If your immigrant spouse stayed past the required departure date on a visa -- no matter how long -- then you're most likely in luck. The immigrant is probably eligible to apply for a green card through a process known as "adjustment of status." This will involve filling out a number of forms (Forms I-130 and I-485 are the primary ones) and submitting them to an office of U.S. Citizenship and Immigration Services (USCIS). As soon as those forms have been successfully submitted, the immigrant's stay in the U.S. becomes lawful, and he or she will receive a U.S. work permit.
Months later, you'll be called to an interview at a USCIS office, and hopefully the immigrant will be approved for the green card.
Of course, the process doesn't always go smoothly. For example, crimes, past immigration violations or other problems could render the immigrant inadmissible. This will be an important area for your attorney to review with you. Also, if the immigrant used the visa as a deliberate way of entering into the U.S. and getting a green card, the green card could be denied on visa fraud grounds.
The immigrant might will a harder time if he or she entered the United States illegally. What's an illegal entry? Examples include stowing away on a truck that entered through a border crossing, paying a "coyote" to help cross a border at an unguarded point, or hiding on a plane or boat to enter the United States.
With an illegal entry, the immigrant becomes ineligible to adjust status in the United States. The exception would be if he or she happens to fall under an old section of the immigration law known as 245(i), which allows adjustment of status by people who had an approvable I-130 or labor certification filed for them either before January 14, 1998 or before December 21, 2000 if the person was also physically present in the U.S. on that date.
Without the right to adjust status, the immigrant's only choice for visa processing becomes to apply and interview at an overseas U.S. consulate. But the consulate has the power to bar the immigrant from returning to the U.S. for a number of years, as a penalty for his or her unlawful stay. The time period is three years for stays of between 180 days and one year, and ten years for stays of over one year. A waiver is available based on extreme hardship to the U.S. citizen spouse or parent, but if the waiver is denied, the immigrant must remain outside the United States. Even more serious is a permanent bar on reentry, which applies to immigrants who spent a year or more in the U.S. unlawfully, left, and then reentered illegally.
If your head is spinning after the above discussion, that's normal. The immigration laws are widely acknowledged to be more complex than the U.S. tax code. Find an attorney -- not just a notary public or someone at your church -- who regularly handles family-based immigration matters and schedule a consultation.