WASHINGTON (AP) – Nearly two years out of the White House, former President Barack Obama is facing another political test.

To the delight of many Democrats, he’s stepped back into the fray that former presidents often try to avoid, campaigning for Democratic candidates ahead of the midterms and blasting the political culture of the Trump era. He attracted a large, adoring crowd this past week in Ohio and will be in Pennsylvania on Friday campaigning for Democratic Sen. Bob Casey.

But Obama’s return poses challenges for both the former president and his party. For one, Obama has struggled to turn admiration for him into votes when he’s not on the ballot. Democrats lost significant ground in the 2010 and 2014 midterms and his enthusiastic campaigning for Hillary Clinton didn’t carry her across the finish line in 2016. Perhaps more importantly, Obama’s public re-entry into politics could serve as a motivating factor for Republicans, potentially handing the GOP a gift at a time when they face an uphill battle to maintain their grip on Congress.

“This is perfect for us,” said Rep. Lou Barletta, the Republican challenging Casey for the Senate seat. “It will energize Republicans as a reminder.”

The former president will also “energize those blue-collar Democrats who worried about their jobs under Obama and went out to vote for Donald Trump,” Barletta added.

For their part, Democrats say an Obama visit is a huge boon. Massive crowds give candidates and the party a chance to organize, update contact lists, motivate new donors and boost volunteerism.

Michael Halle, the campaign manager for Richard Cordray, the Democratic candidate for governor in Ohio, said Obama’s visit sent a message about the stakes of the race, which could have implications for redistricting and voting rights in the future.

Scott Mulhauser, who served as Vice President Joe Biden’s deputy chief of staff during the 2012 election, said Obama left office as the “most admired man in the country, and his popularity has only increased since.”