A bipartisan group of lawmakers introduced legislation on Thursday to end the National Security Agency’s practice of collecting records of Americans’ phone calls and text messages, a push that comes amid uncertainty about the fate of the surveillance program.

Sens. Rand Paul (R., Ky.) and Ron Wyden (D., Ore.) sponsored the legislation. A companion version was introduced Wednesday in the House by Reps. Justin Amash (R., Mich.) and Zoe Lofgren (D., Calif.).

All...