WASHINGTON — President Obama suggested ominously on Friday that allowing domestic surveillance programs to expire at a Sunday deadline could lead to a terrorist attack on the United States.

Pushing the Senate to break a logjam on legislation, Mr. Obama warned in the Oval Office that, “I don’t want us to be in a situation in which, for a certain period of time, those authorities go away and suddenly we’re dark.”

“Heaven forbid we’ve got a problem where we could have prevented a terrorist attack or apprehended someone who was engaged in dangerous activity, but we didn’t do so simply because of inaction in the Senate,” Mr. Obama added.

The comments were the most explicit warning to date from the Obama administration about the consequences of allowing the surveillance powers to lapse. Administration officials have been pressing lawmakers for weeks to pass the legislation, called the USA Freedom Act, and in recent days have stepped up their efforts to portray it as a national security imperative.