RICHMOND — Most of his staff was gone for the night as Gov. Ralph Northam (D) and his wife, Pam, worked the phones in the Executive Mansion. They called friends back in Norfolk, old classmates from his medical school, looking for answers about the racist photo that had emerged from his 1984 yearbook.

When advisers showed up the next morning to what they thought would be the task of helping Northam resign, the near-sleepless governor had a surprise.

“This isn’t me,” he told them Saturday, according to one adviser. Northam was now firmly convinced he was not in the photograph, despite having told the world the night before that he was.

And he wasn’t going to resign.

That set what was already a crisis into uncharted waters, as Northam staged a national news conference and defied calls to step down from virtually the entire political establishment. He wanted to fight, clear his name and avoid becoming the first Virginia governor to resign since the Civil War.

To the outside world, the turn of events seemed almost unfathomable. What Northam and close supporters viewed as defending his honor appeared to others — even his longtime political allies — as hubris, denial and selfishness. To them, his inability to see what was obvious was jeopardizing the Democratic Party both in Virginia and nationally.

“We amplify our call for the Governor to resign,” Virginia’s Legislative Black Caucus said in a statement Saturday after his turnabout. “He has irrevocably lost the faith and trust of the people he was elected to serve. Changing his public story now casts further doubt on his ability to regain that trust.”

The tale of this fast-moving crisis is one of stumbles, miscalculations, and the distance between the way the public came to view Northam and the way he sees himself.

Never a natural politician, Northam, a pediatric neurologist, built his public career on the idea that he was honest. That identity was forged in college, where he enforced the ethics code as president of the Honor Court at Virginia Military Institute.

Northam laid the groundwork for his rise to governor by stumping for Democrats in every corner of the state. Instead of charisma, he had authenticity — the warbly accent of an Eastern Shore waterman — and that built a web of loyalty that paid off with his nine-point victory over Republican Ed Gillespie in 2017.

But his assumption that allies would give him the benefit of the doubt contributed to Northam’s poor handling of the crisis over the photo, according to people close to the governor. And his shock at being so quickly discarded by the party has made it harder for Northam to accept the calls to resign, the people said.

Over the past several days, he has even toyed with the idea of leaving the Democratic Party and governing as an independent — a sign of the degree that he is isolated from every political ally, from his state party and from the national party.

The crisis caught fire quickly Friday afternoon. Social media spread a photograph posted on the right-wing website Big League Politics that showed two people — one in blackface, the other in Ku Klux Klan robes — from the personal page of Ralph Shearer Northam in the 1984 Eastern Virginia Medical School yearbook.

Northam’s first reaction was confusion, according to numerous people who spoke with him as the situation unfolded. He told several people that he didn’t think it was him in the picture, but he couldn’t explain why it was next to other photos that were clearly his.

At the medical school in Norfolk, someone found the yearbook and verified that it was real. Calls were flooding in to the governor’s office. Emails and texts were lighting up devices. Staffers began quizzing Northam, trying to pin down the truth.

“I think it just really froze or rattled his mind,” said a person who was with the governor that day and who, like others in this report, spoke on the condition of anonymity to discuss private deliberations. “His first inclination if someone feels hurt by something he’s associated with or did is to apologize.”

Because the public was demanding a statement, Northam decided to take the blame, according to two people familiar with the events of that evening. He didn’t think it was him but felt responsibility for it being on his page and couldn’t explain how it would’ve gotten there without his participation.

“I am deeply sorry for the decision I made to appear as I did in this photo and for the hurt that decision caused then and now,” Northam said in the public remarks.

Northam sought out African American political figures, and that evening he sat down for an emotional meeting with about 10 members of the Legislative Black Caucus from the General Assembly. Lawmakers said they felt Northam betrayed them, according to people who were present.

“It was a conversation between a man and his friends . . . expressing love and admiration, while also expressing deep hurt and disappointment,” said one lawmaker who was present.

Despite his clear public statement, Northam told the group he was confused by the picture. “He never said it’s absolutely him in the picture. He was in doubt, but understood the implications of the picture appearing under his name,” the lawmaker said.

Later that evening, the caucus members decided that despite feeling some sympathy for Northam, they could no longer see him governing effectively. They called for his resignation.

Such calls had been raining down all evening, but the one from the Black Caucus was especially significant, given the nature of the crisis. Aides and advisers went home that night thinking that Northam would have no choice but to step down the next day.

Northam shifted from his office in the Patrick Henry Building on Capitol Square to the nearby Executive Mansion, and, according to one adviser, spent almost the entire night calling former classmates and checking with people back home. No one there believed he was in the picture.

First lady Pam Northam was particularly insistent that the governor should slow things down and defend himself, several people said.

Saturday morning, Northam told advisers that he was now confident that he wasn’t in the picture, and he wasn’t going to step down.

What’s more, Northam wanted to hold a news conference and take any and all questions the media could throw at him. Some advisers thought this was a bad idea, but they could not dissuade him, according to two people familiar with the situation.

They pressed him on what he would say and whether he was ready to handle a grilling on live national television.

And a new fact would have to be addressed. Northam said that while the yearbook photo was not him, he had in fact darkened his face at another event in 1984 — a dance contest while he was in Army medical school in San Antonio.

He would later tell the news media that he didn’t fully understand the painful legacy of blackface until a conversation with an African American aide just two years ago, when Northam was 57.

By the time of the afternoon news conference in the formal central hall of the Executive Mansion, Northam had had little sleep, according to one person. Upstairs, the Northams held hands with the Rev. Kelvin Jones — their pastor from First Baptist Church in Capeville, who is African American — and prayed.

“I was praying for his strength and for the Lord to wrap his arms around him and his family, and be there for him,” Jones said later.

What followed was a rambling news conference full of cringe-inducing moments.

As dozens of reporters kept pushing for answers about his flip-flop on the picture, communications director Ofirah Yheskel began trying to wrap things up. But Northam kept taking questions — including one about whether he still knew how to moonwalk.

Pam Northam, standing grimly beside him, put out her hand as Northam seemed about to demonstrate and cautioned against it.

His impulse to dance gave the impression that he didn’t appreciate the severity of the situation, and it was skewered by late-night comedians.

Afterward came an outpouring of renewed calls for the governor to resign. Some of Northam’s allies blamed his handlers for allowing it to go forward. “There will be a case study in bad political crisis management in this,” said a close associate of Northam’s who spoke on the condition of anonymity to talk candidly.

A few advisers urged the governor to think about how much he was willing to endure and how difficult it would be for the state if he remained in office.

But he also began to get a trickle of calls of support.

Sunday morning, the Northams traveled to the Eastern Shore and attended church with Jones. The couple received hugs from members of the congregation, Jones said later.

“When the world has beat you up, you ought to always be able to go home and get love,” he said in an interview. “We prayed for him. . . . We just had a celebratory worship service. I think he was truly touched by it. I think he was lifted by it. Because he realized that there are still some true friends in the world.”

The governor and first lady spent most of the day alone, reflecting on what to do.

As his supporters investigated the yearbook photo, trying to track down who was in it and where it came from, the Northams returned to Richmond.

That night and through Monday, Northam held a series of meetings with minority staffers, his Cabinet and eventually most of the administration. He asked them not to quit, to stick with him a bit longer.

“I know he is somebody of honor and integrity, and he is going to clear his name on this,” said state Sen. Richard Stuart (R-Stafford), Northam’s closest friend and perhaps only defender in the legislature. “And I don’t think all the calls for resignation in the world are going to change him in that regard.”

But the continued drama is wearing on many former supporters.

“This protracted exercise has been a painful, embarrassing trial for Virginians and the country as a whole,” AFL-CIO President Richard Trumka said in a statement Tuesday. The union and its Virginia affiliates donated more than $50,000 to Northam during his 2017 campaign. “Gov. Northam’s refusal to step aside is only further deepening the wounds he has inflicted. We call on Gov. Northam to change course and accept the only path that will allow us to heal and move forward together.”