If you are a single individual, it is possible to obtain residency and even citizenship in almost any country by marrying a citizen of that country. Every country is unique and there is a wide range of variance between time it takes to obtain residency and the process to prove that relationship.
Many European countries, and others like many South American countries make it very easy to obtain residency. But others, like the United States, can be a multi-year long headache with lots of paperwork, many gotchas and even interviews before your spouse will ever set foot in the country.
However, not as many people are aware that it is possible to gain residency just by being in a relationship with someone in another country. You will need to prove this relationship and different countries have various requirements. But many European countries will allow you to obtain residency simply by proving you are in a stable relationship with an EU citizen.
The European Union allows any citizen of any country to sponsor you for residency in any other EU country that they are living in. So for example, you could be in a relationship with someone from Poland and living in Portugal and receive Portuguese residency. This will allow you to live, work, and go to school anywhere in the EU with your Portuguese residency and potentially start the clock on obtaining Portuguese citizenship in several years.
As mentioned above, you will need to prove your relationship, and every region is unique but most have either a time requirement (like prove that you have been in a relationship for the last two years) or you will need to formalize your relationship with a notary.
This will then entitle you to a five year temporary residency in the EU. After that, you can apply for permanent residency. At that point you will forever be an EU resident even if your relationship never results in a marriage. This can apply to common-law partners (civil unions, domestic relationships, etc) as well.
I’m not suggesting to go out and get a relationship just for the residency, but if you find yourself in a situation like we described, you should know what options you have.