There are exactly two ways to qualify:
Physical Presence Test
To meet this test, you must be a U.S. citizen or resident alien who is physically present in a foreign country, or countries, for at least 330 full days during any period of 12 months in a row. A full day means the 24-hour period that starts at midnight.
To figure 330 full days, add all separate periods you were present in a foreign country during the 12-month period shown on line 16. The 330 full days can be interrupted by periods when you are traveling over international waters or are otherwise not in a foreign country. See Pub. 54 for more information and examples. [my notes... this means you fly a leg from Bumfrack, Foreign country, over the pond to another foreign country.... that day will not count for your 330 days, since you were not in a foreign country, but instead over international waters.]
Note. A nonresident alien who, with a U.S. citizen or U.S. resident alien spouse, chooses to be taxed as a resident of the United States can qualify under this test if the time requirements are met. See Pub. 54 for details on how to make this choice.
Bona Fide Residence Test
To meet this test, you must be one of the following:
A U.S. citizen who is a bona fide resident of a foreign country, or countries, for an uninterrupted period that includes an entire tax year (January 1–December 31, if you file a calendar year return), or
A U.S. resident alien who is a citizen or national of a country with which the United States has an income tax treaty in effect and who is a bona fide resident of a foreign country, or countries, for an uninterrupted period that includes an entire tax year (January 1–December 31, if you file a calendar year return). See Pub. 901, U.S. Tax Treaties, for a list of countries with which the United States has an income tax treaty in effect.
Whether you are a bona fide resident of a foreign country depends on your intention about the length and nature of your stay. Evidence of your intention may be your words and acts. If these conflict, your acts carry more weight than your words. Generally, if you go to a foreign country for a definite, temporary purpose and return to the United States after you accomplish it, you are not a bona fide resident of the foreign country. If accomplishing the purpose requires an extended, indefinite stay, and you make your home in the foreign country, you may be a bona fide resident. See Pub. 54 for more information and examples.
Line 10. Enter the dates your bona fide residence began and ended. If you are still a bona fide resident, enter “Continues” in the space for the date your bona fide residence ended.
Lines 13a and 13b. If you submitted a statement of nonresidence to the authorities of a foreign country in which you earned income and the authorities hold that you are not subject to their income tax laws by reason of nonresidency in the foreign country, you are not considered a bona fide resident of that country.
If you submitted such a statement and the authorities have not made an adverse determination of your nonresident status, you are not considered a bona fide resident of that country.