The night of his election in 2017 as governor of Virginia, Ralph Northam spoke of America’s racial fault lines, which he said were exacerbated by the White House and had inflamed his own contest.

“Virginia has told us to end the divisiveness, that we will not condone hatred and bigotry — and to end the politics that have torn this country apart,” he said, adding, “It’s going to take a doctor to heal our differences.”

Mr. Northam’s personal past ripped open those wounds over the weekend, threatening to end his governorship 15 months after a decisive victory.

The governor has denied posing for a racist photograph that was published in his medical school yearbook and refused to resign, despite intense pressure from his own Democratic Party.

Mr. Northam, 59, now teeters precariously on the top rung of a political ladder that he ascended in just 10 years, aided by his biography as a pediatrician, an Army officer and a rural Virginian in a state where Democrats have little strength outside cities and suburbs.

His low-key manner, which on the campaign trail manifested as a doctor’s reassurance, appeared to work against Mr. Northam at a news conference on Saturday at the Executive Mansion in Richmond, suggesting a kind of obliviousness. At one point, he seemed on the verge of demonstrating Michael Jackson’s moonwalk — which he said he once did in a dance contest while wearing shoe polish to darken his face — until his wife, Pam, who was standing next to him, whispered, “Inappropriate circumstances.”

Mr. Northam was recruited into politics in 2007 by Levar Stoney, then an official with the state Democratic Party and now the mayor of Richmond. He gave Mr. Northam the nickname “Blue Crab” because of his roots on the state’s Eastern Shore, a center of crab and oyster fishing and farming. Mr. Stoney, an African-American, was among the Democratic leaders who called for the governor to quit.

Mr. Northam was raised on an inlet of Chesapeake Bay, the son of a judge and heir to a long lineage in the racially diverse Accomack County. Today, the small town where he grew up, Onancock, is reached past cotton fields, barns with fallen roofs and the rusty rails of a moribund railroad. Antique stores and real estate offices line the handful of commercial blocks along Market Street.

The governor attended the Virginia Military Institute for his undergraduate studies and then Eastern Virginia Medical School, which is in Norfolk.

At medical school — where the 1984 yearbook included the photograph that now threatens Mr. Northam’s career — the future governor sometimes seemed “a little insecure,” Dr. Rob Marsh, a roommate, recalled on Saturday.

Dr. Marsh, who lived with Mr. Northam for two years, said he had no recollection of the image or any event where it might have been taken. It shows two people, one dressed as a member of the Ku Klux Klan and another wearing blackface, and appears on Mr. Northam’s personal yearbook page.

“I don’t recall that event happening at all, or that picture or anything about that picture,” Dr. Marsh said. “I’m stunned by it. It doesn’t make any sense to me at all — he never had a racist comment or ethnic slur or even joking.”

In the Virginia Senate, he led an effort to ban smoking in restaurants. He later rose on the Senate floor to explain that a Republican bill requiring an ultrasound before an abortion would subject women to invasive “transvaginal” probes. The phrase provoked widespread criticism and mockery of the bill, which Republicans passed after revising it to allow the choice of an external ultrasound instead.

Both issues raised Mr. Northam’s profile. In 2013, he was elected lieutenant governor on a ticket headed by Gov. Terry McAuliffe, a more flamboyant and nationally known figure.

The election season of 2017 thrust the state’s bitter, never fully buried racial history to the forefront. Torch-carrying white nationalists marched in Charlottesville to protest the removal of Confederate monuments, and after the violent death of a counterprotester, President Trump said there were “very fine people” on both sides.

By then, Mr. Northam had invoked his medical expertise in assessing the president’s psychiatric state.

“Being a pediatrician has taught me to listen carefully,” he said in a primary advertisement that began with footage of him examining a boy with a stethoscope and culminated with him declaring, “Now, I’m listening carefully to Donald Trump, and I think he’s a narcissistic maniac.”

While running for governor, Mr. Northam learned that his ancestors had been slave owners. “My family’s complicated story is similar to Virginia’s complex history,” he told The Richmond Times-Dispatch. “We’re a progressive state, but we once had the largest number of slaves in the union.”

Mr. Northam’s Republican opponent, Ed Gillespie, closed his campaign by raising fears of violent Latino gangs and accusing Mr. Northam of backing “sanctuary” cities. He lost by nine percentage points, which was widely seen as a repudiation of the racially charged politics of the Trump era.