That Mr. Obama has stepped in to confront Mr. Trump underscores the vacuum of leadership and coherent message at the top of the Democratic Party, whose titular chiefs are in their 70s and whose next-generation figures have yet to establish themselves as commanding or unifying presences. And his return may play into the hands of Mr. Trump by giving him the public foil he wants.

“I understand the idea that Democrats want to get the former president on the campaign trail as much as possible,” said Jim Manley, a longtime Senate Democratic aide, “but I’m not so sure that makes sense strategically because Trump would love nothing more than to use Obama as a punching bag.”

And neither would Trump allies like Senator Lindsey Graham, Republican of South Carolina. “The more President @BarackObama speaks about the ‘good ole years’ of his presidency, the more likely President @realDonaldTrump is to get re-elected,” Mr. Graham wrote on Twitter. “In fact, the best explanation of President Trump’s victory are the ‘results’ of the Obama Presidency!”

But Mo Elleithee, a longtime Democratic strategist who is now executive director of the Georgetown Institute of Politics and Public Service, said Mr. Obama seemed to be providing a message for Democrats to retake the mantle of populism by arguing that Mr. Trump’s version has actually elevated the interests of the wealthy and powerful.

“He filled a leadership vacuum for the opposition party,” Mr. Elleithee said after the speech, “but what I thought was more interesting is he started to draw a road map for Democrats who are looking for a different way of engaging this populist era and bring us back to a more hopeful approach.”

Still, like other presidents, Mr. Obama does not have a good record helping his party in midterm elections, even when he was in office. Democrats lost the House in 2010 and the Senate in 2014.

After his speech, Mr. Obama dropped by a cafe with J. B. Pritzker, the Democratic candidate for governor, and his running mate, Juliana Stratton, and worked the room. “It’s all about turnout,” he told customers after ordering hot tea and tiramisù. While he extolled a free press in his speech, he took no questions from reporters.