The Senate is about to begin debate on a bill that could, at long last, put an end to the indiscriminate bulk collection of Americans’ telephone records and bring needed transparency to the abusive spying programs that have tarnished the nation’s reputation.

The bill, to be introduced on Tuesday by Senator Patrick Leahy of Vermont, chairman of the Judiciary Committee, is a significant improvement over the halfhearted measure passed by the House in May. That legislation was notable for putting even Republicans on the record in opposition to the broad domestic spying efforts of the intelligence agencies, but its final version was watered down at the insistence of the White House.

Mr. Leahy said at the time that he wanted to write a stronger bill, and, after negotiating with the White House, he has. Both bills would stop the flow of telephone data into the computers of the National Security Agency, keeping the information with the phone companies, where it belongs. But the Senate bill takes a major step in limiting how much of that data the N.S.A. can request.

It would require the agency to ask for the records of a specific person or address it is tracking, instead of conducting a broad dragnet of an entire area code or city in the hopes of turning up something useful. The government would have to show why it thinks the records it requests are related to a foreign terrorist agent. The vague language in the House bill could easily have been exploited by the agency’s lawyers to conduct far more snooping on personal records than is really needed during a terrorism investigation.