Until 2013, it was not publicly known that the equipment installed on network switches was systematically sifting all cross-border internet traffic and sending to the N.S.A. messages containing such a targeted email address anywhere — not just emails to or from targets, but also between other people who talk about them.

The Times first reported the existence of this practice, so-called “about” surveillance, amid the fallout from the leaks by the former intelligence contractor Edward J. Snowden, based on a clue in one of the documents he disclosed and further investigative reporting. From now on, the program will receive and store only intercepted messages that were directly sent to or from a target.

On Friday, Mr. Snowden wrote on Twitter that “the truth changed everything.”

He also called the change “likely the most substantive of the post-2013 NSA reforms, if the principle is applied to all other programs.” However, there was no indication that the N.S.A. intended to cease this type of collection abroad, where legal limits set by the Constitution and the Foreign Intelligence Surveillance Act largely do not apply.

In its statement, the N.S.A. said its failures to comply with the intelligence court rules, which it characterized as “inadvertent,” prompted it to report the problems to the court.

The court issued two short-term extensions of the program rather than reauthorizing it for a full year when a November 2015 order approving it expired. During those extensions, the agency grappled with how it could continue collecting information on surveillance targets without breaking the rules. Ultimately, it said, it decided to limit its upstream internet collection to messages sent directly to or from foreign intelligence targets, forgoing those that are merely about them.

A senior intelligence official said that problems had arisen when analysts queried the raw repository of emails gathered via the upstream program looking for information about Americans. The inquiries were conducted for legitimate intelligence purposes, the official said, but under rules imposed by the intelligence court, analysts were not supposed to search for Americans’ information within that data set.

Analysts are still, however, permitted to search for an American’s information within another repository of emails gathered through the warrantless surveillance program’s so-called Prism or “downstream” system, which gathers emails of foreign targets from providers like Gmail and Yahoo Mail. That system does not collect “about” communications.