CHARLESTON, S.C. — Late on a Sunday night aboard the hulking World War II-era USS Yorktown docked near Charleston, Joe Biden made a surprise appearance to see U.S. Rep. James E. Clyburn, the state's longest-serving congressman and a cornerstone of the black community whose endorsement was coveted in South Carolina.

Clyburn was at a reception with about 200 people. The two friends whose bond was forged over decades together in politics, and who supported each other more recently in grief, found a conference room nearby.

The congressman had been unimpressed with Biden’s presidential campaign operation in the state, frequently hearing about its disorganization and lack of resources. He heard persistent reports that there weren’t enough campaign signs in crucial areas. And he was alarmed by the polling data he’d been shown a few days earlier indicating Biden was clinging to a lead of no more than five points, down from 20 points earlier.

“I just knew they were in jeopardy,” he said.

Clyburn was frank with his advice. Biden was known as being a good guy, and the congressman had experienced the warmth and kindness that Biden can offer. But voters seemed to crave someone with more fight, and Clyburn urged Biden to use a coming debate to more directly take on his rivals.

He also thought Biden’s speeches were too meandering, so he suggested he focus on a few points.

“I said, ‘There’s a reason preachers deliver their sermons in threes. You know, Father, Son and Holy Ghost?’ ” Clyburn said. “Zero in on how to make this personalized, talk about their families, and talk in terms of people’s communities.”

Biden took the criticism to heart. “He told me, ‘I got it,’ ” Clyburn said.

While Clyburn told Biden plenty that night, there was one thing he left out: He had decided that he was going to endorse him.

The Yorktown talk came Feb. 23, midway through an 18-day stretch that has been the most important of Biden’s political career, one in which he tried to revive a campaign so close to collapse at times that one adviser referred to it as a series of “defibrillator moments.”

Former vice president Joe Biden celebrated his first nominating contest win in the 2020 presidential election during South Carolina’s primary on Feb. 29. (The Washington Post)

His campaign had been haunted by small crowds, an absence of energy and a pervasive feeling that the Democratic Party had passed by a 77-year-old out of step with its current contours. Crowds wowed to a host of candidates, including a small-town mayor half Biden’s age who outpaced him in fundraising and, in Iowa and New Hampshire, votes.

Over the course of the Nevada caucuses and the South Carolina primary, the third and fourth contests of this presidential year, Biden would streamline his campaign. He brought in reinforcements, and his campaign aides worked to calm skittish donors.

But perhaps most important, those 18 days saw Biden find firmer footing as a candidate. He reveled in a state he had always considered like home. He received blunt advice from his friends, and took it. He adopted a stiffer edge on two debate stages. His verbal miscues persisted, but even rival campaigns noticed that he was more focused. A grace note came Wednesday, when a nationally televised CNN town hall showcased to the state the empathy-on-his-sleeve candidate who forges emotional connections with voters better than any other in the race.

But until Saturday night, it still was not clear whether that was enough. Voters in the first three states to cast ballots may have seen that side of Biden and respected, even loved him; they may have respected the people endorsing him. But they still didn’t vote for him.

That changed here. South Carolina became the place that a nearly five-decade career, stumbling toward what seemed its end, would at least temporarily be revived. His sweeping victory was the first time in three presidential campaigns that Biden actually won a contest. Everything ahead remained unknown, including whether he could replicate his success when the race turns to a national swarm of primaries on Tuesday. But on Saturday night, his candidacy was at least alive, courtesy of South Carolina.

It had been clear for days: Biden was about to get walloped in New Hampshire.

Sitting in the captain’s chair at the front his “Soul of the Nation” campaign bus, parked outside the DoubleTree hotel in Manchester, N.H., Biden held an intense discussion with his top advisers over whether to stay in the state until the votes were counted or flee toward potentially more friendly environs.

He had invited former governor John Lynch, his top New Hampshire supporter, to come aboard as his team decided, a few hours after the state started voting, that he was not going to stick around to appear before the cameras as a distant fifth-place loser.

“There was a back-and-forth discussion about whether it would have a material impact in New Hampshire if we announced we were leaving before the polls closed,” said Kate Bedingfield, a deputy campaign manager. “But we decided the most important thing to do was to not just tell people that we believed diverse voters should have their say before anyone declared this race over, but to show it. And the only way to show it that night was to take a dramatic step and physically be there in South Carolina.”

So after handing out Dunkin’ Donuts to supporters and shaking hands in a half-filled restaurant, Biden boarded his chartered twin-engine, 10-seat airplane and flew out of the dreary New England weather toward a place that had always sustained him.

“You have no idea how great it is to be back in South Carolina,” Biden said that night in an event space in Columbia, summoning all the confidence his losses in the Iowa caucuses and New Hampshire primary hadn’t beaten out of him.

“It ain’t over, man. We’re just getting started.”

His advisers took some comfort that their gambit to head to South Carolina offered enough drama that television networks carried his remarks live. And they watched as Biden, the longtime front-runner, seemed to relish the only option he had left, battling his way forward.

“I know this is going to be the fight of my life,” Biden said. “But as the old song goes: Lord don’t move my mountain, give me the ability to climb. I can’t do it alone. I need your help to climb that mountain!”

Biden’s campaign always knew that it faced hurdles in the first two states, even if there were moments last fall when his advisers sensed they might be able to overwhelm the field with victories there. He won endorsements, he toured in a bus wrapped with the phrase “No Malarkey” — a decision that some allies complained made him seem hopelessly outdated — and spent significant time and energy trying to win.

But after a fourth-place finish in Iowa on Feb. 3 gave way to the more depressing fifth place in New Hampshire eight days later, the campaign was reeling. Even if advisers had felt he would perform better in what one called “the second two of the first four” states, they did not account for how big of a punch he would take in those first two.

“Obviously we expected to do better in Iowa than we did. And to be clear, we should have been competitive in New Hampshire,” said a senior adviser, speaking on the condition of anonymity to offer a candid assessment. “The fact that we were leading and competitive in polls for a long time demonstrated the appetite voters did and do have for Biden. But the reality is, we couldn’t come in where we did in Iowa and hope to have a stellar showing in New Hampshire.”

Between the two contests, Anita Dunn, a senior adviser and Biden confidante, was elevated and given final decision-making authority. The campaign also tapped a widely respected Democratic operative, Jen O’Malley-Dillon, to come in and run the Nevada operation.

But blame also rested elsewhere — on Biden himself.

After the New Hampshire loss, Biden’s campaign co-chairman Rep. Cedric L. Richmond (D-La.) wrote him a tough-love email: “If you really believe you’re fighting for the soul of the country, then go act like it.”

“I think he was being too cautious,” Richmond said. “After New Hampshire we were like, ‘Throw caution to the wind. Go be you. You’re not going to be a perfect candidate. You’re not going to be a robot. Just go be you.’ ”

“If we’re fighting for the future of the country, then let’s go fight for it.”

Aides attempted to focus Biden’s message, refining a speech that even on good days can feel like a stream-of-consciousness vent. And a candidate who had spent the past year orienting himself as the alternative to President Trump began instead casting himself as the Democratic Party’s chief alternative to Sanders.

Biden sought to drive home that Sanders had a record more favorable to gun manufacturers. He continued to hammer away at the costs of Sanders’s signature Medicare-for-all plan, and the risks to the party of having a democratic socialist as the standard-bearer.

But Biden also benefited from something he could not control — other candidates’ desperation as their odds of winning lengthened. As one adviser said, “Biden’s success in some ways is built on other people’s disappointments.”

Sanders and former South Bend, Ind., mayor Pete Buttigieg had shaken the field with their strong performances in the first two contests, knocking back Sen. Elizabeth Warren and Biden. Sen. Amy Klobuchar’s surprisingly strong third-place finish in New Hampshire further muddled the moderates, while former New York mayor Mike Bloomberg spent a fortune to brand himself the most capable alternative to both Sanders and Trump. Businessman Tom Steyer also spent heavily in South Carolina, beginning to peel black voters away from Biden.

The debate in Las Vegas on Feb. 19 unleashed a new dynamic among candidates, with Warren being particularly animated in attacking everyone onstage but especially Bloomberg, whose poor performance began to give voters pause.

“I have to give a little bit of credit to Elizabeth Warren, to her surgical takedown of Mayor Mike,” said Larry Rasky, a Boston-based consultant who knows Warren and Biden well and is helping run the super PAC supporting Biden.

Bloomberg’s fall came to Biden’s benefit as voters continued to look for a more moderate option. “Results matter. And things shifted,” Rasky said.

On a Saturday afternoon in Las Vegas, 11 days after New Hampshire and seven before South Carolina, Biden and his team watched results from the caucuses. A candidate who had slumped from fourth in Iowa to fifth in New Hampshire had finished second in Nevada. It was a distant second, but his trajectory had reversed.

“Even though Bernie did well, that we came in second was important,” said John Anzalone, a Biden adviser and pollster. “It showed we were still alive.”

Biden arrived back in South Carolina on Sunday morning, Feb. 23, and headed to Royal Missionary Baptist Church in North Charleston. When other presidential candidates had come to the church, they spoke in side buildings on the campus. Biden, though, was granted the center of the sanctuary for a crowded Sunday service.

It was a visible reminder that he had deeper connections in the state than other candidates and that his campaign was buttressed by black voters whose role had not been visible until South Carolina but who would make up the majority here.

“The thing about the African American church is that it’s all about hope,” he said after thanking the people who’d allowed him the moment. It was clear his hope was not simply spiritual.

“This is real,” he said. “The African American community in South Carolina will make a judgment about who the next president is going to be. . . . You have in your hands the power to decide, to determine who the next Democratic nominee will be. . . . You can own this election.”

Over the next few days, Biden gathered with aides inside a hotel suite at the Mills House hotel in the historic downtown of Charleston, where the beds had been cleared out and, in their place, a large circular conference table was brought in.

The next debate would be widely watched in South Carolina, and they knew these sessions would be crucial. Rather than do a mock debate, they batted around ideas. They talked about ways for Biden to be more direct in his points, how to hammer Sanders and how to take on Steyer among African Americans.

“The truth is when he’s on the debate stage he’s very, very, very careful not to misspeak or get any little thing wrong, which can cause a problem all in itself,” said Richmond, the campaign co-chairman. “We were saying, ‘Look, don’t worry about that. People make mistakes. But if you try so hard not to make any mistake, you’re going to paralyze yourself.’ ”

“He’s getting more comfortable trusting his instincts,” he added. “He doesn’t have to get it all in for an answer. He has to get the main points in and get them in forcefully.”

On the debate stage Feb. 25 he was, at times, so forceful that it surprised some of his advisers. The candidate who in the first debate said, “My time is up” as he voluntarily stopped talking was now chastising the moderators for not giving him more chances to speak. For one of the first times in a presidential primary debate, Biden seemed to have a hometown crowd, with frequent cheers at his answers.

The next morning brought another pivotal turn. A few days earlier, Clyburn had been at the funeral of his accountant when an older woman beckoned him to her pew. She whispered in his ear — who are you voting for? — and said others were looking to him for guidance.

He paused before telling her Biden was his choice. And he decided he would publicly say so the next Wednesday, the morning after the debate.

Clyburn delivered a glowing and deeply personal endorsement. He recounted how Biden comforted him when his wife had died a few months earlier. Biden, hugging Clyburn, was moved to tears.

There were three days to go before South Carolina voted.

South Carolina had always been different, both demographically and in Biden’s mind.

“Joe Biden is at home when he’s here, ” said Symone Sanders, a senior adviser who relocated after the New Hampshire primary and had been living in the state for weeks.

It was the state’s long-serving Sen. Ernest “Fritz” Hollings who convinced a grief-stricken Biden to take his U.S. Senate seat after Biden’s wife and daughter died in a car accident just after his 1972 election. Biden’s family would often vacation in South Carolina, and his extended family came to Kiawah Island just south of Charleston in 2015 as they mourned the death of Biden’s oldest son, Beau.

When he dies, Biden has said, he wants to be reborn in Charleston. Still, even here the campaign struggled.

Only after the New Hampshire loss, some close to the campaign say, did the campaign truly begin to invest in the state, hiring paid canvassers, increasing spending on radio ads and sending senior staffers to the state.

“South Carolina is his territory, and we’ve leveraged his relationships here,” said Kendall Corley, the state director of the campaign. “We went out and had real conversations with voters, with elected officials. And tapped into their enthusiasm.”

Biden’s campaign operation has often been a mess. Internally, decisions tended to get bottled up at the top and delayed. On the ground it was so disorganized that volunteers attempting to help would be turned away.

His campaign even overlooked a group of about a half-dozen long-standing informal black advisers who were so loyal that they referred to themselves as the Bidenites. Miffed that the campaign hadn’t asked for their support as he sought the presidency for the third time, some members had migrated to Steyer. Others had joined up with the campaign of Rep. Tim Ryan (D-Ohio) before he dropped out in October.

“We said, ‘To hell with it. If they don’t want us, to hell with it,’ ” recalled Fletcher N. Smith, a former state legislator who was in the group. But after Biden lost in New Hampshire, his campaign here started reaching out to people like Fletcher and another Bidenite, Brandon Brown.

“They were like, ‘We need you guys back,’ ” Smith recalled.

The Bidenites had grown worried about the rise of Sanders, fearing that if he were the nominee the party would lose the House and Senate.

“We all just made a determination that whatever differences we may have had in the past, Biden is still our man,” Smith said of the Bidenites. “This is not anything about a personality or ego or anything personal. It’s about the business of politics.”

Their informal group activated, drawing on its political and religious networks. Smith began working the phones and traveling the state, propping up Biden and knocking Sanders. A group that had been on the outside looking in, frustrated with the campaign operation, was now back on board.

On Friday, Smith introduced the vice president at Wofford College, Smith’s alma mater.

“The Joe Biden I know respects both his friends and his adversaries,” he said. “The Joe Biden I know cherishes his Irish roots and his Catholic faith. The Joe Biden I know didn’t hesitate to join the administration of the first black president of the United States.”

Smith sat onstage with Biden for the rest of the event, including as Biden offered his thanks.

“Fletcher Smith, you have been a good friend for a long, long time,” Biden said, “and I really appreciate your friendship.”

On Saturday night, his win was so resounding that the election was called for Biden as soon as the polls closed at 7 p.m.

Preliminary exit polls of South Carolina’s voters showed the success of the tactics Biden employed over the 18 days. About three-quarters of Democratic primary voters viewed Biden favorably, a far better standing than enjoyed by any other candidate.

More than half of primary voters were black. And nearly half said Clyburn’s endorsement was important in deciding their vote.

A slew of new challenges begin with Tuesday’s contests. Several candidates are in better financial shape than Biden and have deeper organizations. It may not last, but for the first time in a long time, Biden on Saturday was basking in good news.

“For all those of who have been knocked down, counted out, left behind — this is your campaign,” he said, before alluding to those who had predicted, after his first three losses, that his campaign was dead.

He let out a broad smile, leaned into the microphone and proclaimed: “We are very much alive.”