Democratic Rep. Tim Walz, a candidate for Minnesota governor, gives a pep talk to football players at Como Park Senior High School in St. Paul on Monday, Aug. 13, 2018. Walz was one of several candidates in the race for governor and other elections making last-minute campaign stops ahead of the Tuesday primary. (Kyle Potter/AP)

— Democratic gubernatorial candidate Tim Walz jumped out of a school bus full of volunteers here Saturday morning, ran through the suburban crowd and tried to convince voters that he could move their state to the left.

“It’s time to put a public school teacher, labor leader into the governor’s office,” Walz said. “It’s going to be progressive Minnesota that stands up and says, ‘Enough!’ ”

Walz, a six-term congressman from rural Minnesota, had run in the past with the backing of the National Rifle Association; he once aired TV ads accusing a Republican foe of voting “to give 50,000 illegal aliens amnesty.”

Not anymore. President Trump lost the state only narrowly in 2016 and has made it a top target for his reelection campaign. Once, that might have forced Democrats to the center. Instead, in recognition of the dominant activist energy, they have turned a deeper shade of blue and argued for the party to move left in Tuesday’s primaries.

Republicans, here as elsewhere, saw the 2016 election as the start of a conservative wave and are hewing closer and closer to the president — making Minnesota an example of the nation’s swing away from the middle and toward the political poles.

The changes wrought in 2016 have affected not only the candidates’ positioning but also where they are delivering their messages. As in most of the Midwest, Democrats had typically competed for Minnesota by winning the cities and competing in rural areas with strong labor traditions; Republicans had won by winning in suburbs and exurbs.

That changed in 2016, as Democrats ran up their vote in the Twin Cities, and in suburbs where they had rarely been competitive, but lost badly in outlying parts of Minnesota.

Few other states have so much up for grabs this year. Both U.S. Senate seats are on the ballot, and all but one statewide constitutional office is open. Three House seats are open, from Walz’s 1st District, to Minneapolis’s 5th District, to the 8th District that covers Duluth and the state’s Iron Range — once a Democratic labor bastion, won by Trump.

“I went to parades in the Iron Range this year, and I’ll tell you, it was the best reception I got anywhere in the state,” said Doug Wardlow, who is vying to be the state’s first Republican attorney general since the 1970s — and may face Rep. Keith Ellison, a Democrat who is one of the most left-wing members of Congress and who spent the final ­pre-primary hours trying to fend off accusations of misconduct by a former girlfriend.

In this year’s race for governor, Walz’s positioning as a proud progressive is shared by every Democrat, sparking a debate over who has a right to that mantle. The state’s Democratic Farmer Labor Party, or DFL, gave its official endorsement to Erin Murphy, a liberal state legislator from St. Paul who is running on a promise to bring single-payer health care to the state.

At the party’s June 2 convention, Murphy pushed past Walz on the seventh ballot, in part by stoking doubts that a congressman who had only recently evolved on gun-control issues could be trusted to lead on them as governor.

“I’ve always gotten an F from the NRA, and Minnesotans need to know who is going to stand with them on this issue,” Murphy said in the final pre-primary ­debate this week.

Walz has said he has evolved on the gun issue and always been a pro-labor liberal on other issues. “The NRA you see now is not the NRA when they were teaching us gun safety classes when we were growing up,” he told the state news website MinnPost last year. On the trail, he says his experience attracting votes in a part of the state that little resembles the urban center of Minneapolis will help him not just win, but build consensus when he does.

The race heated up with the last-minute candidacy of Lori Swanson, the state’s longtime attorney general, who usually received positive NRA ratings. Dogged by accusations over whether she politicized her office, Swanson does not portray herself as a moderate; her final ad blitz includes one accusing Walz of failing to “stand up to Trump” by skipping House votes, and a super PAC supporting her campaign has sent out mail that pairs the years of Walz’s NRA endorsements with the years of deadly school shootings.

The Republican primary had been equally unfriendly. Tim Pawlenty, a two-term governor who ran for president in 2012 then led the Financial Services Roundtable, a business lobbying group, returned to state politics on the theory that no strong Republican was running. Jeff Johnson, the party’s unsuccessful 2014 candidate, refused to step aside.

While Pawlenty leads in polls and money, the two men have sparred for weeks over who can be trusted to govern as a conservative — and who has been most loyal to Trump. Pawlenty has been running ads that warn about welfare and benefits being wasted on “people who aren’t supposed to be here,” as images of immigrants climbing a border wall splash on the screen. In another ad, he reminds voters Johnson, who backed Sen. Marco Rubio (R-Fla.) in the 2016 primary, once called Trump a “jackass.” (The word itself is blurred out.)

Johnson, who won the party’s convention vote after Pawlenty declined to compete for it, has argued Pawlenty would throw away a winnable election because he could not credibly run on the policies that pulled Trump to a near-victory in the state in 2016. At every opportunity, he has reminded voters that Pawlenty abandoned Trump after the release of an “Access Hollywood” tape where he could be heard boasting about grabbing women’s genitals.

“I supported him,” Johnson said at a debate this month. “You told people not to vote for him.”

The loyalty to Trump has surprised Democrats, who point out Minnesota was the only Midwestern swing state he did not win. The 2016 exit poll found that just 35 percent of Minnesotans viewed Trump favorably, and polling since then has found his approval rating stuck at or below 40 percent. In a similar environment, 12 years ago, Republicans scrambled away from an unpopular George W. Bush, with the party’s U.S. Senate candidate that year even renouncing his vote to invade Iraq.

In one of two Senate races, all the fire has been on the left. Democratic Sen. Amy Klobuchar has drawn an underfunded Republican opponent, while Sen. Tina Smith, the Democrat appointed in January to replace Al Franken after he resigned under accusations he groped women, has consistently led Republican Karin Housley in money and polls.

Before she faces Housley, Smith has to put away a challenge from Richard Painter, a former ethics lawyer for the Bush White House, who gained cable news fame as a Republican who said Trump needed to be removed from office.

Democrats expect Smith to easily defeat Painter, who has raised less than $250,000 for his campaign and who soundly lost at the party convention. But on his first run for any office, Painter has tapped into the anger of Democrats who feel their party is not doing enough to oppose the president.

At his town halls, which draw out dozens of voters, Painter generates applause when explaining how both Trump and Vice President Pence could be removed from office and asking why the senator who replaced Franken — who, he says, should not have resigned — is not doing the same.

“She’s on TV with these nice ads, having doughnuts and coffee with people,” Painter said dismissively at a Thursday event in St. Louis Park. “I don’t have the money to run those ads. But I’ll buy doughnuts and coffee for the Senate Judiciary Committee when I get there.”

In interviews at Painter’s town halls this week, multiple voters used the same word — “timid” — to describe Smith.

“She just seems weak,” said Marilyn Wehler, 68, after listening to Painter at a library in St. Louis Park. “I like Painter because he has a spine.”

Smith, like Franken, has spent her first months as a senator avoiding media attention and TV hits where senators can weigh in on the controversy du jour. She also has broken with this year’s convention to put herself in the political center.

In an interview, she said Minnesota was a “Democrat-ish” state, not one where politicians could ignore independents and conservatives. Rather than attacking Trump, she is focused on her years of lower-profile state government work — she was lieutenant governor when appointed to replace Franken — and the insight it gave her into the most rural, conservative pockets of the state.

“I felt very strongly that I needed to show Minnesotans that I was up to the job,” Smith said after a canvass launch in a northern Minneapolis suburb. “I’ve been fierce about fighting the president on the issues where I feel he’s been flat-out wrong.”

Correction: An earlier version of this story misspelled Karin Housley’s name. It has been corrected.