WASHINGTON — Two senators claimed on Thursday that the Justice Department had secretly interpreted the so-called Patriot Act in a twisted way, enabling domestic surveillance activities that many members of Congress do not understand.

At the same time, Congress and the White House were rushing to enact legislation to prevent a lapse in several of the federal government’s investigative powers under the Patriot Act that were set to expire at midnight. The Senate passed the bill 72 to 23 late in the afternoon, and within hours the House approved it 250 to 153. In an unusual move, a White House spokesman said that President Obama, who was in Europe, would “direct the use” of an autopen machine to sign the bill into law without delay.

During the debate, Senator Ron Wyden, an Oregon Democrat and a member of the Intelligence Committee, said that the executive branch had come up with a secret legal theory about what it could collect under a provision of the Patriot Act that did not seem to dovetail with a plain reading of the text. “I want to deliver a warning this afternoon: When the American people find out how their government has secretly interpreted the Patriot Act, they will be stunned and they will be angry,” Mr. Wyden said. He invoked the public’s reaction to the illegal domestic spying that came to light in the mid-1970s, the Iran-contra affair, and the Bush administration’s program of surveillance without warrants.

Another member of the Intelligence Committee, Senator Mark Udall, Democrat of Colorado, backed Mr. Wyden’s account, saying, “Americans would be alarmed if they knew how this law is being carried out.”