WASHINGTON  When it comes to the deficit, Ben S. Bernanke has a story, and he’s sticking to it.

Mr. Bernanke, the Federal Reserve chairman, warned on Wednesday that “the federal budget appears to be on an unsustainable path,” but also recognized that an “exceptional increase” in the deficit had been necessary to ease the pain of recession.

In nearly two hours of questioning by the House Budget Committee, however, Mr. Bernanke gave potential succor to members of both parties, while refusing to side with either of them.

To Republicans, he offered warnings about the fiscal perils of an aging population and the potential threat of soaring long-term interest rates. To Democrats, he made it clear that persistently high unemployment was a drag on growth and said that additional short-term stimulus spending might be needed.

All the while, Mr. Bernanke refused to endorse any particular spending cuts or tax increases, or even specify the balance between the two. And he was not subtle about his strategy.