WASHINGTON — Senator Patrick J. Leahy said Thursday that next week he would file a new version of a bill aimed at ending the National Security Agency’s bulk phone records collection program after extensive negotiations with the Obama administration and privacy groups.

Mr. Leahy, a Vermont Democrat who is chairman of the Senate Judiciary Committee, has been leading the negotiations, and several officials familiar with the deliberations said a deal had been reached. Because the Senate leaves for its August recess at the end of next week, it is unlikely to vote on the bill before September.

Mr. Leahy’s draft bill is said to make over a dozen changes to a version of the legislation, called the U.S.A. Freedom Act, that the House passed in May. Some privacy advocates who had denounced the House bill as too watered-down said they backed Mr. Leahy’s draft.

“The Center for Democracy and Technology supports the draft language we’ve seen,” said Harley Geiger, a senior counsel for the advocacy group. “It is, in every instance, a step forward and an improvement on what the House enacted.”