LAS VEGAS — Former president Barack Obama was onstage at the University of Nevada, Las Vegas, Monday, doing a familiar, uncomfortable job.

He was here to rally Democrats and to fight cultural tides the party didn’t quite anticipate.

It’s a pattern that began in Massachusetts back in early 2010, when Obama flew to Boston to save a special election that had come out of nowhere to nearly kill Obamacare's chances in the Senate. Here in Nevada, the Trump moment that was supposed to sweep Sen. Dean Heller away seems instead to have kept the Republican senator alive in Nevada, a state Hillary Clinton won two years ago.

“The current senator — he doesn’t seem to be willing to stand up to this,” Obama told an audience of 2,000 in a gymnasium, avoiding mentioning the senator by name, and adopting a tone of amused disappointment. “He just goes along — even when you get a sense that he knows it’s not right.”

Obama spent much of his speech on a long defense of his own presidency, and condemnation of Republican governance.

“When you hear all this talk about ‘economic miracles’ right now, remember who started it,” Obama said. He denounced Trump’s attempts to pressure the FBI and Department of Justice to target political foes.

“That is not how America works. That is how some tin-pot dictatorship works,” he said.

But Obama didn’t come to Nevada to make news, and he mostly didn’t. This is the box he’s in now. Even as he’s edged away from the tradition of post-presidential silence, there’s a more practical reason for his muted campaigning: He’s said to be afraid his presence would backfire, give Trump a foil, and energize the Republicans who Democrats hope will stay home in November.

The voters here were happy to see him. The vintage hip-hop act Salt-N-Pepa opened up by dedicating the song “Whatta Man” to Obama. The young Nevada Democratic Party chair, William McCurdy, couldn’t contain his excitement: He’d never met Obama before, he said, and stressed that the former president’s role was to “rally [the] voters.”

That rallying is, in Nevada, very focused on young Latinos, who make up the Democrats’ edge here — if they vote. The headliner to that effect was the reggaeton star J Balvin.

“If we can’t find a way to activate the largest and fastest-growing demographic in this country, there’s no way we can take our country back,” actor America Ferrera told the crowd.

Obama and Democrats here are up against a Republican campaign in Nevada that embodies the surprisingly durable politics of Trump’s party. A little over a year ago, Heller seemed doomed: He had vocally opposed Donald Trump in 2016, declaring himself “100% against Clinton, 99% against Trump.” (He granted nine months after the election that he had voted for Trump.)

Now Heller is an emblem of everything going right for the party of Trump: a president who finds it possible to focus, and forgive, on politics; and a renewed cultural backlash that has helped Republicans across the country.

Heller embodies his party: The senator flirted with independence, and Trump openly threatened him into supporting the unpopular attempt to repeal Obamacare. Then Heller spent time with Trump after the 2017 Las Vegas shooting, and found his way back into the president’s good graces. He has stopped criticizing the president, started voting with him, and been rewarded by political support.

“Everything you touch turns to gold,” Heller told Trump the other day.

Nevada Rep. Jacky Rosen, in Las Vegas Monday, repeated that line.

“Seriously,” she marveled. “He said that.”