Generally, a homeowner must own and live in the home for two out of the last five years to qualify for the $250,000 ($500,000 if filing a joint return) exclusion for capital gain on the sale of a primary residence. However, there is an exception to the two-year rule for tax payers who sold early for a job-related move. You meet the standard requirements if any of the following happened during the time you owned and lived in the home you sold:
If you meet this and the other requirements for the capital gains exclusion, you're entitled to a percentage (in your case, 75%) of the exclusion amount.
Please follow this link for more information. https://www.irs.gov/uac/about-publication-523
Could you please confirm this is the case also for US citizens living abroad and selling a foreign primary residence?
Nothing in the Internal Revenue Code nor Treasury Regulations relating to the Section 121 home sale exclusion requires that your principal residence be located within the United States in order to qualify for the exclusion.