WASHINGTON — The National Security Agency discovered in October 2018 that it was collecting information about domestic phone calls and text messages that it had no legal authority to gather, newly disclosed documents show, underscoring the troubles the agency has had with using Americans’ phone records to hunt for hidden terrorist cells.

The N.S.A. blamed the incident on an unidentified telecommunications provider, saying that agency technicians had noticed a problem with the data that the company was sending, and stopped accepting the information in order to fix it. The episode came to light on Wednesday in documents the American Civil Liberties Union had obtained via a Freedom of Information Act lawsuit.

The disclosure was the latest in a long string of episodes in which the N.S.A. has experienced technical difficulties complying with rules when trying to handle large volumes of Americans’ domestic phone records. The agency currently does so under the USA Freedom Act of 2015, which is set to expire at the end of the year unless Congress extends it.

Patrick Toomey, a staff attorney with the A.C.L.U.’s national security project, said the disclosure underscored privacy issues that argue for Congress to let the program lapse.