In the thick of the Republican presidential primary contest earlier in the year, Sen. John F. Kerry (D-Mass.) suggested he would participate in 2012 presidential electioneering only reluctantly.

“I have little interest in inserting myself, as a former nominee of my party, into this presidential campaign season,” the failed 2004 Democratic presidential candidate wrote in a letter to The Washington Post in March.

Kerry is long past any such qualms now.

The Massachusetts Democrat is using his home-state history with Republican candidate Mitt Romney and his rare front-line experience in presidential debates to help President Obama get ready for his three matchups with Romney this fall.

Kerry and Obama have had one shirt-sleeves practice session, with Kerry playing the role of his old Massachusetts political adversary. More mock debates are planned before the first Obama-Romney debate Oct. 3.

The goal of the practice sessions is to test Obama’s rhetorical skills against an impersonator who says what Romney would say, and who looks and sounds as much like the former Massachusetts governor as possible.

“He may end up being a better Romney than Romney, and if that happens, that’s good,” Democratic strategist Bob Shrum said.

Kerry also has a prominent speaking role Thursday at the convention, where he is expected to blast Romney’s foreign policy ideas as naive or reckless.

Previewing his arguments in Foreign Policy magazine, Kerry lamented the loss of bipartisanship in confronting national security threats and praised Obama’s “balanced approach.”

“We don’t need the simple slogans and conflicted policy positions the opposition offers up,” Kerry wrote.

Both candidates consider the debates crucial and have devoted chunks of the summer to preparing. Romney’s team is using Sen. Rob Portman of Ohio as a stand-in for Obama. In-person rehearsal sessions began this week.

In addition to the acting job, preparation involves fat binders of research and the debating equivalent of watching the opponent’s game films.

Kerry has the advantage of being able to study Romney’s very recent debate performances during the GOP primaries. He also has the advantage of a striking physical resemblance to Romney. Both men are tall, angular and patrician in bearing, and both can come off as stiff.

For a politician sometimes mocked for his love of the limelight, the debate-preparation job is a decidedly off-stage role. Kerry declined to be interviewed for this article.

When Kerry’s stand-in job was announced in June, Kerry backers said he could be a “secret debate-prep weapon,” because he knows Romney’s career and background well.

Kerry proved adroit in debates against a Republican Senate challenger, Gov. William Weld, in 1996. Although Romney’s positions have shifted right, his background as a moderate Massachusetts governor parallels Weld’s.

Kerry and Romney never ran against each other, but even in the context of brawling Massachusetts politics, the two are widely considered to dislike one another. Kerry dismissed Romney as a dilettante trying to buy Edward M. Kennedy’s Senate seat in 1994, and Romney famously labeled Kerry a policy flip-flopper.

“I don’t want presidential leadership that comes in 57 varieties,” Romney said in 2004. “I want George W. Bush!”

Shrum arranged a series of similar mock debates for Kerry in the 2004 presidential race, with Washington lawyer Gregory Craig playing the role of then-President Bush. Shrum, who is not involved this time, said Kerry’s dogged preparation for past debates for his own elections will serve him well even while arguing the opposite of his own views.

Kerry was an early Obama supporter, and in his role as chairman of the Senate Foreign Relations Committee he became a trusted messenger for difficult diplomatic missions in Afghanistan, Pakistan and elsewhere.

Kerry is frequently mentioned as a possible secretary of state in a second Obama term.

Julie Tate contributed to this report.