Twelve years earlier, they shared that stage as opponents in a bitter Senate race. Back then, Mr. Romney accused Mr. Kennedy of waging “untrue, unfair and sleazy” personal attacks. Now, the Republican governor was introducing the liberal Democratic senator as “my collaborator and friend.” Mr. Romney’s complicated relationship with Mr. Kennedy, from campaign foe to health care partner, helped shape both his political career and his image. Today, as a Republican candidate for president, he is courting conservative voters, a constituency that does not look kindly upon Mr. Kennedy or the Romney approach to health care, which will come under scrutiny again this week when the Supreme Court takes up challenges to a similar measure championed by President Obama. But try as he might to distance himself, Mr. Romney cannot escape Mr. Kennedy’s influence. On the campaign trail, he uses the senator, who died in 2009, as a foil, denouncing Mr. Kennedy’s “liberal welfare state” policies and boasting of how Mr. Kennedy “had to take out a mortgage on his house to make sure he could defeat me.” He has said losing to Mr. Kennedy was “the best thing” that could have happened to him, “because it put me back in the private sector.” Mr. Romney’s attempt in 1994 to “out-Kennedy Kennedy,” as people here say, led him to take stands on issues like abortion and gay rights that he has since backed away from, giving rise to accusations that he is a flip-flopper. Mr. Kennedy’s tough campaign advertisements, which portrayed Mr. Romney as a cold-hearted financier, rattled him, and his bruising loss in the race “viscerally pained” him, one friend said. But he emerged tougher, convinced that it is better to punch first than to counterpunch later — lessons his campaign is putting to use today. “Romney was the young up-and-comer in ’94 who thought that the aging champ had lost his edge and was then surprised to get knocked out,” said Rob Gray, a Republican strategist who advised Mr. Romney in his 2002 race for governor. “That certainly caused him to reassess how any future campaign should be built.” The two men could not have been more different. Mr. Kennedy was the back-slapping Irish pol with the rakish past; Mr. Romney the upstanding businessman who viewed Mr. Kennedy with some disdain. While they eventually joined forces, theirs was a transactional relationship. Despite Mr. Romney’s glowing Faneuil Hall introduction, they never truly became friends. “I just don’t think they spoke the same language,” said Scott M. Ferson, a former Kennedy aide and Romney neighbor who became a bridge between the two. They did extend courtesies to each other. Mr. Kennedy lent his support to the construction of a Mormon temple in Belmont, Mass., a project just minutes from Mr. Romney’s home and dear to him. Later, as governor, Mr. Romney turned up during the 2004 Democratic National Convention in Boston for the dedication of a ribbon of parks named for Mr. Kennedy’s mother, Rose. But it was their work on health care, a lifelong passion for Mr. Kennedy, that may have had the most enduring impact on Mr. Romney. The legislation gave him national standing to run for president in 2008, only to emerge as a political liability in the current campaign in a way that neither man could have foreseen. “It’s an irony with a capital I,” said Jeffrey M. Berry, a political scientist at Tufts University who followed their careers. “From the grave, Ted Kennedy is involved in the Republican race for the presidency.” Mr. Romney and Mr. Kennedy entered the 1994 Senate race as strangers, but their families had been circling each other for decades. Mr. Romney was 15 in 1962, when Mr. Kennedy was first elected to the Senate. That same year, George W. Romney, Mitt’s father, was elected governor of Michigan; Mr. Kennedy’s brother, President John F. Kennedy, campaigned for his Democratic opponent. Decades later, the elder Romney — who had once worked with Senator Kennedy on legislation promoting volunteerism — prodded his son to run for the Senate seat Mr. Kennedy occupied.