WASHINGTON (AP) — The National Security Agency is defending its tracking of foreign cellphones overseas. It says the practice is legal under a U.S. presidential order governing all U.S. government spying.

The agency said Friday it isn't tracking every foreign phone and call, and that it takes measures to limit how much U.S. data is collected.

The Washington Post reported this week that the agency is gathering location data for up to 5 billion cellphones globally every day, including some American data, according to documents from former NSA contractor-turned-fugitive Edward Snowden.

Spokeswoman Vanee (Vuh-NAY) Vines says the practice is legal under a White House order that governs U.S. espionage, known as Executive Order 12333. She says NSA analysts must treat any U.S. citizens' data they accidentally gather differently.

Also on HuffPost:

Loading Slideshow...
  • Edward Snowden

    This June 9, 2013, file photo provided by The Guardian in London shows Edward Snowden, who worked as a contract employee for the National Security Agency, in Hong Kong. (AP Photo/The Guardian, Glenn Greenwald and Laura Poitras, File)

  • Edward Snowden

    In this image made from video released by WikiLeaks on Oct. 11, 2013, former National Security Agency systems analyst Edward Snowden speaks during a presentation ceremony for the Sam Adams Award in Moscow. (AP Photo)

  • Edward Snowden

    A frame grab made from AFPTV footage, reportedly taken on Oct. 9, 2013, shows U.S. intelligence leaker Edward Snowden speaking during his dinner with a group of four retired U.S. intelligence workers and activists at a luxurious room in an unidentified location. (AFPTV/AFP/Getty Images)

  • Edward Snowden

    In this image made from video released by WikiLeaks on Oct. 11, 2013, former National Security Agency systems analyst Edward Snowden smiles during a presentation ceremony for the Sam Adams Award in Moscow. (AP Photo)

  • Edward Snowden

    In this image made from video released by WikiLeaks on Oct. 11, 2013, Edward Snowden (center) receives the Sam Adams Award in Moscow. (AP Photo)

  • Edward Snowden

    This photo, taken June 9, 2013, in Hong Kong, provided by The Guardian in London shows Edward Snowden, who worked as a contract employee for the National Security Agency. (AP Photo/The Guardian)

  • Edward Snowden

    This handout file photo taken on July 12, 2013, and made available by Human Rights Watch shows NSA leaker Edward Snowden during his meeting with Russian activists and officials at Sheremetyevo airport, Moscow. (AP Photo/Tatyana Lokshina, Human Rights Watch HO, file)