DES MOINES — The last time Democrats scouted for a presidential nominee who could strip the White House from Republicans, the party supported additional fencing along the U.S.-Mexico border. Same-sex marriage was illegal in 49 states, and few Democratic candidates were pushing to change that. And only one long-shot presidential hopeful talked about “Medicare-for-all.”

A dozen years later, Democratic candidates and potential ones now argue that more barricades are not what is needed at the border. Candidates who once dodged questions about same-sex marriage now support it and are calling for greater protection of transgender individuals. “Medicare-for-all” — or something like it — has become standard, along with promises to combat racism, sexism and global climate change.

For years, Democratic presidential candidates have been skittish about taking positions that were considered too liberal, for fear of scaring off moderates and independent voters. That caution seems to be gone, along with soul-searching about making explicit appeals to conservative voters.

It has been replaced by confidence — whether real or mistaken — that a more liberal and populist Democratic Party can form a majority out of voters who either support the sweeping changes candidates have proposed or will vote for anyone other than President Trump.

It’s not just Democratic candidates who have undergone a political transformation — the party’s voters have also shifted to the left on many issues in recent years and have become much more partisan. Nine in 10 Democrats supported stricter laws covering the sale of firearms in a 2018 Gallup poll, up from about 2 in 3 a decade earlier. Forty percent of Democrats and Democratic-leaning independents support increasing legal immigration, according to Pew Research Center data, up from 20 percent in 2006. And support for same-sex marriage has increased among Democrats and Republicans.

A Pew Research poll in early 2018 found that 46 percent of Democrats identified themselves as liberal, up from 28 percent a decade earlier. The percentages calling themselves moderate or conservative each slumped by high single digits.

“The party is made up of the people. It’s the people first. And I think as people, we are understanding issues more and more because the information, the access to the details is readily available to us every single day,” said Deidre DeJear, a longtime voting rights advocate in Des Moines who was heartened to see voter suppression taken seriously during the midterm elections. “And I think that’s what’s helping to shape the party is the people who are part of it — and I think that’s how it’s supposed to be.”

The party’s swift shift has left vulnerable several Democratic candidates or likely ones who have voting records and previous stances that are out-of-line with current Democratic thinking. Those who defend their earlier stances risk seeming stuck in time to party that’s quickly transforming, while those who have changed their positions risk being labeled as flip-floppers and opportunists.

Former vice president Joe Biden, who is contemplating a run, has defended his leading role in the Senate passage of the 1994 Violent Crime Control and Law Enforcement Act, which activists say accelerated the rate of mass incarceration and disproportionately affected minorities. He has apologized for his treatment of Anita Hill in the early 1990s when she accused Clarence Thomas, then a Supreme Court nominee, of sexual harassment.

Sen. Kamala D. Harris (D-Calif.), who announced her candidacy for president Monday, has faced questions about her actions as a prosecutor and attorney general of California, including her push to criminalize truancy and punish parents whose children miss school or arrive late.

Rep. Tulsi Gabbard (D-Hawaii), another presidential candidate, apologized in a three-minute video last week for “wrong” and “hurtful” things she said while working with the Alliance for Traditional Marriage, an anti-gay group that opposed same-sex marriage. Gabbard said her “views have changed significantly since then.”

During a Friday night house party in Sioux City, Iowa, a likely caucus-goer asked Sen. Kirsten Gillibrand, the New York Democrat who announced her campaign days earlier, to explain how her rating from the National Rifle Association quickly fell from an “A” as a House member to an “F” as a senator.

Gillibrand said that early in her political career, “I only really looked at guns through the lens of hunting,” but she changed her mind after meeting with two Brooklyn parents who had lost their daughter to gun violence.

“I just felt convicted that I had done the wrong thing,” Gillibrand said.

As Gillibrand traveled across Iowa last weekend, she was greeted by longtime Democratic voters, some of whom said they’ve undergone similar evolutions in their political beliefs — and that it’s healthy to do so. Even in the most conservative areas of the state, local party leaders shrugged off concerns that liberal platforms would scare off voters.

“If she’s put more thought and study in it, and sees it a different way, I have no problem with that,” said Kris Begne, 55, who works in human resources at an insurance company and saw Gillibrand during her two-day visit to the state. “That’s what you should be doing, if you’re human. If you’re reading and learning and watching TV, if you’re studying any issues, you should be open to changing your mind. Otherwise, why have a conversation with anybody?”

Tim Winter, the chairman of the Boone County Democratic Party, who introduced Gillibrand at a Saturday morning gathering, said that his own views on gun control have evolved over the years: As a young man who loved pheasant hunting with his friends, he didn’t think any gun laws were needed. Now, as the father of two young children, he thinks lawmakers need to draw lines, especially when it comes to assault-style weapons.

“You progress,” he said. “We always call ourselves progressives because you can kind of change your mind about some things if you want to learn more about what actually works.”

Teresa Wolff, a longtime Democratic organizer in the Sioux City area, said her two grown daughters are often “enlightening me on things I have held firm on.” Even though Wolff has long considered herself a feminist, she said her daughters will sometimes reprimand her for hesitating to speak out or privately saying that a female candidate “needs to wait, learn her place” before running for office.

While Wolff says she has always supported same-sex marriage, she remembers a time when it was just not an issue that was publicly discussed — and now her daughters are coaching her on LGBTQ issues and helping her understand gender matters.

“They’re bringing us along with them. They’re dragging some of us out of our safe Democratic beliefs — and that’s part of the growing process,” Wolff said. “Always having white people with the same opinion about everything gets us nowhere — clearly, it has gotten us nowhere in the past 25 years. We need to start looking like what we say we stand for and represent.”

Most prominent Democrats aren’t publicly challenging this evolution, citing the party’s successes during the midterm election, when Democrats won races in rural areas that had voted for both Obama and Trump. In some of those cases, however, the Democratic nominees beat out candidates with more liberal positions in the primaries.

Republicans are already painting the opposition as completely out of touch with most Americans and too liberal to win back the White House from a president who in 2016 demonstrated appeal in culturally conservative states that usually voted with Democrats.

The Republican National Committee has labeled Gillibrand a “chameleon” for her shifting positions and tried to paint all candidates as egotistical and caring more about their political careers than voters. The Catholic Association, which opposes abortion, reacted to Harris’s campaign announcement in a statement that highlighted her support of abortion rights and said that “this mentality did not serve Hillary Clinton well in key battleground states like Pennsylvania, Ohio, Wisconsin and Michigan.”

Iowa, the earliest-voting state, is the sort of place where Republicans hope they can continue to win the votes of Democratic-leaning independents who are scared off by the party’s shift to the left.

Iowa saw a dramatic shift away from Democrats in 2016. Thirty-two of the state’s 99 counties voted twice for Barack Obama, then for Donald Trump; rural Democratic legislators who had held office for years were swept out in the wave.

Among the flash points in the state’s turn to the right has been immigration, an issue that alienated some Iowans, particularly white voters without college degrees, from the Democratic Party.

Tom Vilsack, the former agriculture secretary who was Iowa’s governor from 1999 to 2007, remembered producing a 30-year plan for the state at the turn of the century, suggesting that it could become a hub for immigrants — and being blown back by the reaction.

“The people putting that plan together were thinking of bringing physicists from Poland, but a lot of Iowans who saw the plan though we were talking about people from Central America,” said Vilsack. “You could give people data that new immigrants weren’t taking their jobs, and they wouldn’t be convinced.”

In the run-up to the 2008 caucuses, most Democrats talked carefully about immigration, stopped short of endorsing same-sex marriage and assured gun owners that no one would challenge their Second Amendment rights. Tommy Vietor, who traveled with Obama as his Iowa press secretary, recalled that even at Democratic events, the candidate was asked about the specter of immigrants taking American jobs.

“He would go to events with some of the most progressive people in the state, and someone would stand up and ask: ‘What are you going to do about illegal immigration?’ ” Vietor said. “He’d start with the whole litany of punitive proposals, from people ‘going to the back of the line’ to how they needed to learn English.”

Trump, whose campaign made animosity to immigrants a central theme, won the state in 2016 by almost 10 points.

By the end of Obama’s presidency, most Democrats no longer talked about “illegal immigration.” This year, against the backdrop of the president refusing to fund the government without money for a border wall, Democratic candidates in Iowa have promised to oppose him.

In 2018, the party did not recover its strength in most rural areas and lost a race for governor that had been seen as winnable. But Democrats flipped two of the state’s four House seats, electing Rep. Cindy Axne (D-Iowa) and Rep. Abby Finkenauer (D-Iowa) in races in which liberal solutions for health care and other issues were at the forefront.

“There’s so much more willingness now to go to a single-payer system,” said Bret Nilles, the Democratic chairman in Linn County, a population center in Finkenauer’s district. “Ten years ago, I thought we’d never get to that point.”

Chelsea Janes and Emily Guskin contributed to this report.