At pivotal moments, Virginia Gov. Ralph Northam (D) has built his political career on denunciations of his state’s racist past, attacking Confederate monuments and energetically courting African American voters.

But Northam — whose early successes, including a long-sought Medicaid expansion, have been a bright spot for Democrats — on Saturday found himself in a place no politician wants to be in 2019: explaining on national television how hard it was to remove shoe polish from his face after a dance routine. He said he darkened his face in the 1984 routine to imitate Michael Jackson and the moonwalk.

His extraordinary public appearance Saturday laid bare the tensions that have gripped the commonwealth and the country since Friday afternoon, when a photograph from the governor’s 1984 medical school yearbook page emerged showing people in blackface and Ku Klux Klan robes.

After initially apologizing for his presence in the image, Northam reversed course on Saturday, saying he was not one of the costumed figures. Those denials were in line with statements from several of Northam’s classmates, who said they had never seen him in the kind of offensive garb pictured on his yearbook page.

But Northam’s defense was offset by several admissions he made during his first extended remarks since the photo became public. Among them: He had applied shoe polish to his face to impersonate Jackson while he was in the Army and did not fully realize until his 2017 campaign, during conversations with a black aide, that what he had done could have been seen as offensive.

“I had the shoes, I had a glove and I used just a little bit of shoe polish to put under my, or on my cheeks, and the reason I used a very little bit is because — I don’t know if anybody’s ever tried that, but you cannot get shoe polish off,” Northam told a crowd of reporters who listened in stunned silence at the governor’s mansion.

“I actually won the contest because I had learned how to do the moonwalk,” he added.

Such statements, coming from an elected official committed to advancing racial equity, were in a sense characteristic of a state that has long been defined by unresolved tensions: Between its economically booming north and agrarian south, a Republican legislature and a Democratic governor and, perhaps most importantly, between black and white.

Built upon centuries of slavery and segregation, Virginia was home to the capital of the Confederacy and to a demonstration by white supremacists in Charlottesville that led to a deadly riot in 2017.

It was also the first state to elect an African American governor — L. Douglas Wilder, who held the seat now occupied by Northam from 1990 to 1994. Justin Fairfax, the state’s black lieutenant governor, would replace Northam if he is forced to step down.

Such contradictions are embodied in the strange circumstances surrounding Northam’s racist yearbook page. Several of his classmates from medical school — some of them black — said they were astonished by the offensive photograph and could not bring themselves to see the amiable young physician they had known as a racist.

“The Ralph that I know wouldn’t do something like that. He never showed any of those kinds of attitudes, never, during the entire time we were there,” said Walter G. Broadnax Jr. “I’m just dumbfounded by it all.”

Broadnax, a retired neurologist who is African American and now lives in Chesapeake, Va., after years practicing in Cincinnati, described Eastern Virginia Medical School in 1984 as a tolerant campus where he never detected overt racial bias from other students.

That description was echoed by Tobin Naidorf, who also graduated in 1984 and is now a gastroenterologist in Alexandria. Naidorf, who is Jewish and originally from Northern Virginia, said his medical school lacked many of the outdated Southern attitudes he had seen as an undergraduate at the University of Virginia.

Naidorf said the offensive outfits on Northam’s yearbook page would have been unacceptable at medical students’ social gatherings. Far from being an outpost of bigotry, Naidorf said, the school was populated by idealistic young medical students eager to practice in low-income communities.

“If anything, EVMS was founded on humanistic principles to provide care to the underserved population in Tidewater,” Naidorf said. “I never saw anything like that at parties.”

Naidorf said that he did not know Northam well during their time at the school, but that his impression was of a “nice guy, soft-spoken.”

E. Franklin Roberts, an African American obstetrician in Virginia Beach, was a year ahead of Northam at EVMS. He said students of the same race sometimes stuck together, but not always. He said a sense of camaraderie in the face of the medical school’s demands brought students together, and they would frequently drink together on Friday nights.

Attention also has also turned to Northam’s college years at Virginia Military Institute, in particular a yearbook that listed one of his nicknames as “Coonman.” Northam said Saturday that the name was bestowed upon him by upperclassmen and that he could not explain it.

Benjamin B. McClellan, Northam’s first-year college roommate, said he had never witnessed racist behavior by Northam or others at VMI.

“Obviously we were in Southern Virginia. I would imagine it was in the region, but I never heard or saw anything,” McClellan said. “I never saw that side of him at all and I don’t know if that picture was an anomaly. I don’t have any idea.”

An anomaly is exactly how Northam described the picture Saturday, saying he did not submit it to the yearbook staff and believed it had been placed on his page by mistake.

Pamela Kopelove, who is identified in the yearbook as its editor, did not respond to repeated calls for comment. Other yearbook staff members could not be reached. Both Naidorf and Broadnax said there were no mistakes on their yearbook pages and that the photos on their pages were ones only they could have submitted.

EVMS President Richard V. Homan said in a statement that the photograph on Northam’s page was “shockingly abhorrent and absolutely antithetical to the principles, morals and values we hold” and that he would be convening a meeting of school leaders to address the issue. “It has been said that those who fail to learn from history are condemned to repeat it,” he added.

Some experts said that the spectacle of students in blackface was not as surprising in 1980s Virginia as some might like to believe.

“Virginia and the South in the 1980s had barely moved beyond Jim Crow,” said Julian Hayter, a historian who focuses on 20th-century American history at the University of Richmond. “Many people who were in college in the 1980s were raised by people who knew nothing but segregation and had intolerably archaic views even then.”

VMI didn’t hire its first black professor until 1988, according to a 1999 article in the Journal of Blacks in Higher Education, and the first black students matriculated in 1968 and graduated in 1972.

The transition from white supremacy to a more integrated and multicultural population in formerly all-white institutions created anxiety for people unprepared for change, Hayter said.

Before the rise of social media, people in primarily segregated institutions “felt safe — they did these things in ‘polite’ company that they didn’t expect to become public, to be held accountable for,” Hayter said. “They’re a product of their time and culture.”

Northam, who grew up outside a town of fewer than 2,000 people on Virginia’s rural Eastern Shore, alluded to the commonwealth’s unsavory past in his remarks on Saturday.

“In the place and time when I grew up, many actions we rightfully recognize as abhorrent today were common place,” he said, without providing further details.

Northam also said that he had worked in recent years to better understand the perspective of African Americans. His 2017 campaign was marked by frequent visits to black churches. On Saturday, he spoke of a road trip during the gubernatorial race with his assistant Seth Opoku-Yeboah.

The governor said the topic of blackface performances — which originated with 19th-century “minstrel shows” in which white performers would portray African Americans in demeaning ways — came up, and he told Opoku-Yeboah about the Michael Jackson performance.

“I assume you probably would think that’s offensive,” Northam recalled saying.

“I would,” Opoku-Yeboah replied.

Northam recounted his response: “I apologize for what I’ve done in the past and I can promise you I’ll never do that again in the future.”

On Saturday, Northam again found himself apologizing, with little effect.

As the evening wore on, state Democratic lawmakers called on him to resign. The state’s two Democratic U.S. senators, Mark R. Warner and Tim Kaine — who had stopped short of calling for him to go after the photo emerged on Friday — issued a joint statement urging him to step down.

For those who had admired Northam and expected much out of his next three years in office, it was a harrowing spectacle. A politician who acknowledged his state’s troubled past, and his own, was trying to move forward. But he could not move fast enough.

Patricia Sullivan and Antonio Olivo in Washington and Jim Morrison in Norfolk contributed to this report.

Earlier versions version of this article said the first black cadets did not graduate from the Virginia Military Institute until 1975. They graduated in 1972.