There is a fair chance you can get full or at least partial relief from this ruling, depending on the circumstances behind your move.
There are many exceptions to the rule laid out by the IRS. Among those possibly applicable to you would be if you were forced to sell because your job or place of employment was moved, you suffered health issues requiring a move or endured "unforeseen circumstances." The latter includes the occurrence of an event or events "that you could not reasonably have anticipated before buying and occupying your main home," according to IRS Publication 523. Among those are a death, divorce, separation, natural or man-made disaster and multiple births.
If you vacated the house for health or medical reasons, you will need to have a physician letter on hand documenting those conditions. You need not file it with your taxes but should keep it with your records in the event the IRS requests "additional information." The job-transfer rationale can apply to either of you because you are married.
Those two years of occupancy, by the way, need not be consecutive, which is a relevant factoid in the event you plan to reoccupy the place or have reoccupied it at any point as a main residence since the time you two moved. If it turns out you lived in your home less than a cumulative two years before it sells, you may still be able to exclude a portion of any gain. Of course, your tax attorney is best suited to walk you through all the various steps and nuances.
As an aside, be sure to price your old place to market realities to jump-start the sales effort, lest your listing grow staler and staler.
Good luck with the sale and the tax man! Here's hoping you enjoy a handsome profit -- and a tax-exempt one at that.
Ask the adviserTo ask a question of the Real Estate Adviser, go to the "Ask the Experts" page and select "Buying, selling a home" as the topic. Read more Real Estate Adviser columns and more stories about mortgages.