Can I use the capital gains exclusion if bought the home from a renter? We have lived here for over 3 years but only owned it officially for 2 years.

My mother in law purchased a home for us to rent from her. We later bought it from her offically. We've lived at this residence for 3 years, and have owned it for 2. We rented it out the last few months of ownership. Can we claim the year prior to owning as the residency exclusion on capital gains?