WASHINGTON — The National Security Agency used its warrantless surveillance program to help Turkey find the suspect in a terrorist attack at an Istanbul nightclub on Dec. 31 that killed 39 people and wounded dozens more, including an American who was shot, a senior F.B.I. official said Tuesday.

The surveillance program’s role in hunting down the suspect was one of several newly declassified examples that national security officials, including Carl Ghattas, the head of the F.B.I.’s national security branch, divulged at a Senate Judiciary Committee hearing about the FISA Amendments Act, the legal basis for the program. The law will expire at the end of 2017 if Congress does not extend it.

But the pitch by the security officials to persuade lawmakers to extend the law or make it permanent ran into political turbulence, including continuing anger by Republicans over the leaking of the contents of calls in December between Michael T. Flynn, President Trump’s former national security adviser, and the Russian ambassador. Those disclosures helped lead to Mr. Flynn’s ouster from the administration.

Senator Lindsey Graham, Republican of South Carolina, said he had asked months ago whether the government had ever intercepted his conversations with foreign leaders and, if so, whether any executive branch officials had requested that his identity be revealed in intelligence reports based on those calls.