Q: After renting it out for 11 years, we're re-taking possession of our home. How long must we live there to qualify for the $500,000 capital gains exclusion when we sell?
A: The IRS covers the ownership and use requirements in Topic Number 701 - Sale of Your Home
In general, to qualify for the [tax code] Section 121 exclusion, you must meet both and ownership test and a use test. You're eligible for the exclusion if you have owned and used your home as your main home for a period aggregating at least two years out of the five years prior to its date of sale.
You can meet the ownership and use tests during different 2-year periods. However, you must meet both tests during the 5-year period ending on the date of the sale.
Generally, you're not eligible for the exclusion if you excluded the gain from the sale of another home during the two-year period prior to the sale of your home.
Refer to Publication 523 - Selling your Home for the complete eligibility requirements, limitations on the exclusion amount, and exceptions to the two-year rule.
Some flexibility in the 5-year/2-year ownership and use periods may be available if you or your spouse are on qualified official extended duty in the Uniformed Services, the Foreign Service or the intelligence community.
As with all tax matters, it's best to engage a tax professional to see how these items apply to your situation.