Mr. Romney “struck me as someone who was more interested in having the job as governor than doing the job,” said Gov. Deval Patrick of Massachusetts, a Democrat and close friend of Mr. Obama who succeeded Mr. Romney. Mr. Patrick said his predecessor, whom he describes as “a gentleman,” seemed to be someone who said to himself, “O.K., I won that, now I’m going to move onto something else.” Former Senate colleagues of Mr. Obama said the same about the future president.

There is a restless quality to both Mr. Obama and Mr. Romney, people close to them say. They spent formative periods living abroad and attended several colleges before carving out political careers as above-it-all outsiders. They had their convictions questioned by ideological purists in their parties (and their religions, too, by others).

Each suffered tough losses in early campaigns that might have, in retrospect, been ill-advised: Mr. Romney lost a 1994 Senate race in Massachusetts against the incumbent, Edward M. Kennedy; Mr. Obama was crushed in a 2000 Democratic Congressional primary in Illinois by the incumbent, Bobby L. Rush.

While each was the product of a doting and strong mother, the candidates forged their identities in part through the specters of their fathers — or the absence of one, in the case of Mr. Obama.

“Someone once said that every man is trying to either live up to his father’s expectations or make up for his father’s mistakes,” Mr. Obama wrote in his 2006 book, “The Audacity of Hope.” He has repeated the line often, sometimes adding that both might be true in his case.