ANAMOSA, Iowa—Nothing has gone the way it was supposed to for Bruce Braley.

The Democratic congressman, who is behind in the polls in his race to represent Iowa in the Senate, is sitting on a couch in a nearly empty coffeeshop in this small town east of Cedar Rapids that houses Iowa’s largest prison. (“The population is about 6,000, but 1,200 of them aren’t allowed to leave,” one local tells me.) Braley is trying to put a good face on a campaign where nearly everything has gone wrong.

“I’ve always known this was going to be a tough race,” says Braley, a blue-eyed 56-year-old with a thin fuzz of brown hair. This is what every politician on the wrong side of the numbers always says, and it's rarely true. Plus, Braley says, he feels like the tide is turning in his favor. “There's so much positive momentum, especially coming off the last two debates”—a seeming acknowledgement that his performance in the first of the three debates was lousy. Among his supporters, he says, he is sensing “a tremendous amount of energy.”

For some reason, Braley’s campaign stop here—he walked down Main Street, ducking into a couple of shops before stopping for a cup of coffee and a chat with the mayor here at Grounds & Goodies—was not advertised, and rather than come out to greet him, the whole town seems to have retreated indoors. Main Street is empty; there are six people in the coffeeshop. On this campaign stop, Braley will come into contact with no more than a dozen voters.

Braley could be the perfect mascot for Democrats in an election year where almost nothing has gone their way, and the party’s chances of holding on to the majority of the Senate seem to get dimmer by the day. A year or so ago, Braley seemed poised to ascend to the Senate with minimal trouble. He was running in a state President Obama won twice, the last time by 6 percentage points; his party was unified behind him, and his potential Republican opponents, a clown-car’s worth of no-namers, were busy tearing each other apart in a messy primary. “Democrats have the advantage here,” the Cook Political Report said of Iowa in December 2013, “and their prospects could get even brighter.”

What a distant memory that seems now. Braley's opponent, state Senator Joni Ernst, has led in five straight public polls, by an average of 2.5 percentage points. His fellow Democratic candidates can relate. In past election years, Democrats have been able to rely on Republicans squandering opportunities thanks to infighting, inept candidates, and campaign missteps. But this year, it is Democrats who have made the mistakes, while the GOP has produced compelling, relatively gaffe-free candidates and unified around them. The national mood continues to darken, and Obama’s approval ratings continue to slide, dragging down Democrats everywhere. And Braley is—for the moment at least—losing to a woman who’s served a single term in the Iowa legislature and who was virtually unknown until a few months ago.

Braley, who has been in Congress since 2006, can barely hide his contempt for Ernst. She does not know this state like he does, he tells me. “My opponent lived in Southwest Iowa and did not have the opportunity to spend as much time traveling around the state as I have in my life,” he says. “In 23 years practicing law, I represented clients all over the state of Iowa. I have relatives in various different parts of the state. I represented 23 counties in Congress before I ran for the Senate.” Ernst, he maintains, is too conservative for the state: “I think she supports an extreme Tea Party agenda, and it’s bad for Iowa.”

Braley’s message, however, has been obscured by Ernst’s star power: A Harley-riding, gun-toting self-described “farm girl” with a hardscrabble upbringing who served in Iraq as a National Guard commander. And Braley’s own campaign has been a never-ending comedy of errors, most notably the video of him ridiculing Republican Senator Chuck Grassley as “a farmer from Iowa who never went to law school” to an audience of out-of-state campaign donors. Obtained by a Republican PAC and released in March, the footage is still being featured in some of the many attack ads outside groups are airing on Iowa television. There was also an absurd controversy involving therapy chickens belonging to a neighbor of Braley’s vacation home. “It has been a tough campaign,” a leading Iowa Democrat who is not working for Braley tells me. “I think he expected a somewhat easier path.”

When I mention the farmer fracas, Braley, who has been asked about it a million times, tries not to look pained. “Look, we all say things we regret,” he says. “I would assume Senator Ernst has said things during this campaign that she regrets.” He doesn't say what those might be.

* * *

About 100 miles away in Sigourney, 40 Iowans are waiting for Joni Ernst in a back room of Bob Sinclair’s John Deere dealership. Gigantic farm machines, painted shiny green, crowd the gravel lot. Inside, an air of anticipation hangs over the room. “Did you see her walk by the door?” one woman says to her companion. Tanya Webster, the 43-year-old chair of the Keokuk County GOP, rushes into the room wearing a big grin. “I got to hug Joni Ernst!” she exclaims. Her day has been made.

When Ernst enters—wearing jeans and a mustard-yellow blazer, her short gray-flecked brown hair parted to one side—Webster can hardly contain her excitement. “At our fall fundraiser, the No. 1 topic was, ‘How do we get Joni here?’” she says. “We’ve been wanting to get you here for months!”

Ernst wasn’t the Republican Party’s first choice for this contest—Iowa’s first open Senate seat in 30 years, freed up by the retirement of Democrat Tom Harkin. Republican bigwigs tried to get Tom Latham, a popular congressman, or Kim Reynolds, the lieutenant governor, into the race, but both declined. The significant war chest Braley was building up—thanks in large part to his fellow trial lawyers, one of the Democratic Party’s most generous interest groups—might have helped to scare them off. (On the other hand, the GOP establishment breathed a sigh of relief when Steve King, the Tea Party congressman known for inflammatory remarks about immigrants, took himself out of the running early.)

Ernst was one of five little-known candidates in the primary. National Republicans, seeing the race as a long shot, favored Mark Jacobs, a businessman who told them he would be willing to spend as much as $4 million of his own money on the contest. But Ernst famously broke out of the pack with a commercial in which she announced that, having grown up castrating hogs on an Iowa farm, “I know how to cut pork ... Let’s make 'em squeal.”

Even after Ernst won the primary—with a resounding 56 percent of the vote—there were doubts about whether she would be able to raise money or move away from some of the far-right views she’d expressed in the past. But Ernst proved to be a polished and disciplined campaigner. National donors flocked to her—she raised $6 million in the third quarter of this year, an Iowa record and double Braley’s fundraising. In Iowa, her colorful bio and natural charisma have made her a star. Grassley goes so far as make a comparison that is surely his highest praise: She is “a little bit like ethanol,” he says. “It’s good, good, good, and let me assure you, Joni Ernst is good, good, good.”

Ernst has a plainspoken, folksy appeal, with a nasal Midwestern accent that only makes her seem more authentic. Her stump speech is not long on detailed policy prescriptions. She talks about low taxes and less burdensome regulation and getting rid of the Affordable Care Act. “High taxes, Obamacare—we can’t do it!” she says. Cow farts play a prominent role as she blasts the EPA for supposedly wanting to restrict farm methane emissions. “How do you regulate that? I have no idea!” she says, to laughter. “But evidently Bruce Braley thinks we should regulate what’s coming out of our cows and hogs.”

Ernst is also running on the record of the state’s popular governor, Terry Branstad, who will become the nation’s longest-serving governor when he is almost certainly reelected to a sixth term this year. Iowa’s economy is booming, its unemployment rate one of the best in the nation at 4.6 percent. “That’s the Iowa way, and that’s what we need to do at the federal level,” Ernst says. Branstad, who leads his Democratic opponent by double digits, is said to be obsessed with winning every county in the state. There are two he’s never won before; to reach one of them, Lee County, in the state’s far southeast corner, he’s bought television ads in the neighboring Quincy, Illinois, market. Democrats worry Branstad, having ensured his own reelection, will devote his extra campaign funds to increasing Republican turnout.

Branstad, a mustached moderate who has accepted Obamacare's Medicaid expansion funds, tells me Ernst was part of his “team” in the Iowa legislature while Braley was serving in the unpopular Congress. “This is the contrast: The Iowa way versus the Washington, D.C., way,” Branstad says. “It’s all conflict and confrontation and blaming other people.” Ernst, he says, has “been an Iowa problem solver.” Describing Braley, Branstad sounds personally affronted: “He’s an arrogant trial lawyer who says bad things about our beloved Senator Grassley and our Iowa farmers!”

Braley has tried to focus Iowans’ attention on the right-wing views Ernst expressed in the past. She has shown an interest in impeaching Obama, nullification of federal laws, and the Agenda 21 conspiracy theory, a far-right paranoia about United Nations control. During last year’s government shutdown, she said she would not have voted to reopen the government. She opposes the federal minimum wage and backs a federal “personhood” amendment that would criminalize all abortions and possibly some forms of contraception. This week, a recording from 2012 emerged in which Ernst talks about using her handgun to defend herself “from the government, should they decide that my rights are no longer important.”

Yet Braley has had trouble getting people to believe that Ernst, with her friendly, accessible demeanor, is actually a wild-eyed right-winger, and she has not given him much new ammunition. A recent Des Moines Register poll found Iowans agreed with Braley on six of 10 top policy issues—yet more of them had a favorable impression of Ernst than of Braley. This fact has bedeviled Braley’s campaign, Jeff Link, a top Braley adviser, tells me. “If you look at her, you wouldn’t assume she would have such unreasonable positions,” he says. “She looks like a reasonable person, but she has an unreasonable point of view.”

At the candidates’ first debate, Ernst was asked to name an example of the onerous federal regulations she decries. “Cap and trade would be one example,” she said. “Not only is it an increased tax to Iowans, but it would also cost Iowans an additional thousand dollars in utility costs every year.” Braley responded by noting that cap and trade couldn’t be hurting the economy because it never became law. “Did the stories say she didn’t know cap and trade was law? No,” Link says. “But all the stories all said she was confident, she smiled, she seemed friendly. So that’s a challenge.”

Ernst has been campaigning in a mad sprint, trying to cover all 99 Iowa counties before Election Day. (She had eight stops the day I followed her.) At the same time, she has turned elusive with the media, turning down interviews with newspaper editorial boards perceived as hostile to her campaign, including the state’s largest, the Register, which endorsed her in the primary. The interview I was promised with her was cut off after just two questions. Following up on another reporter’s question, I tried to clarify her position on abortion—she said she wanted to “promote a culture of life,” but that “there is a law in existence right now.” Did that mean she wouldn’t seek to change Roe v. Wade, I asked? “I am going to encourage lots of people to support life. That’s who I am,” she said. “But has it changed over the past 40 years? No, it has not.”

I asked her about Braley’s depiction of her as an extremist, and she chuckled fondly. “He would like to think that I am that type of person,” she said. “But I do bring people together. We all need to work together .... He’s just trying to push people away from my candidacy when I’m the Iowan that cares about people and making sure they have better opportunities.” Then her spokeswoman cut her off and rushed her back to her waiting campaign bus, which features a giant photo of her smiling face and, down below, a little picture of a pig.

* * *

Braley doesn’t have a campaign bus. He arrives at Flapjacks Family Restaurant in Maquoketa in a black SUV instead, heading to the basement for a meeting with a dozen local Democratic activists.

The activists seem worried. Bob Osterhaus, a former state representative who owns a local pharmacy, says he hears a lot of talk about Obama. “I’d like to suggest you be more forceful,” he tells Braley. “I have been very forceful!” Braley insists. Another activist remembers the worst days of 2010, when Braley held a health-care town hall and was booed when he tried to respond to a young woman who accused him of not having read the Affordable Care Act. For Democrats, it feels like the bad times are here again.

“You know what, you don’t have an action shot of you doing stuff on a farm,” says Buck Koos, a county superviser who also owns a feed store. “I’ve got a lot of feed that needs to be unloaded, and you’re wearing jeans.”

“Bag or bulk?” Braley says, grinning. “I’ve delivered a lot of feed in my day!” A lot of people don’t seem to realize that he, Bruce Braley, is also connected to authentic Iowa agricultural life. He talks about this for a while, for emphasis. But the people in this room already know, and it's not clear anyone else is listening.