WASHINGTON — For a day, at least, President Barack Obama and Republican Mitt Romney stopped assailing each other and spoke as heartbroken parents.

The Colorado movie theater massacre upended the presidential campaign on Friday, obliging both candidates to cast aside the increasingly bitter tone of the race and reach for a rare moment of American harmony.

Yet the moment itself was a political test, for a president charged with consoling a nation and for a challenger needing to show that he could rise to the occasion.

“There are going to be other days for politics,” Obama said from key electoral state Florida. From another, New Hampshire, Romney said much the same.

It was more than an unusual case of agreement between the political foes. At times, they sounded just like each other, speaking of evil and of prayer, of the unfulfilled dreams of those killed, of the need to put aside daily and petty grievances to appreciate life and show compassion to others.

The president openly wondered of his 14- and 11-year-old daughters: “What if Malia and Sasha had been in the theater?”

Addressing a crowd that had gathered for what was expected to be a raucous political rally, he said somberly, “Michelle and I will be fortunate enough to hug our girls a little tighter tonight, and I’m sure you will do the same with your children.”

Likewise, Romney said to his audience, “Each one of us will hold our kids a little closer.”

He said, “I stand before you today not as a man running for office, but as a father and grandfather, a husband, an American.”

Amid their calls for unity and prayer, both men said nothing of gun control, a polarizing issue that has been all but absent from the campaign debate this year. Both Romney and Obama have shifted with the times, moving away from stances that favored tougher gun control laws.

The issue might rise anew. New York City Mayor Michael Bloomberg, a gun control advocate, said, “You know, soothing words are nice, but maybe it’s time that the two people who want to be president of the United States stand up and tell us what they are going to do about it.”

On Friday, Obama and Romney swiftly stripped their day of overt campaigning that surely would have seemed crass given the enormity of the tragedy. They scrambled to yank all their television spots, attack ads or otherwise, from Colorado stations — though strongly critical ads continued elsewhere.

Both campaigns pulled their top surrogates off Sunday’s politically driven talk shows.