WASHINGTON - President Barack Obama said for the first time Friday that he had held back before Election Day from retaliating against Russia for meddling in the presidential race for fear of inciting further hacking "that could hamper vote counting."

But he said he was weighing a mix of public and covert actions against the Russians in his last 34 days in office, actions that would increase "the costs for them."

Obama said he was committed to sending the Kremlin a message that "we can do stuff to you," but without setting off an escalating cyberconflict.

"There have been folks out there who suggest somehow if we went out there and made big announcements and thumped our chests about a bunch of stuff, that somehow it would potentially spook the Russians," he said. "I think it doesn't read the thought process in Russia very well."

The president did not reveal what steps he was considering if he decided to retaliate against the Russians and suggested that some of the options, if they were carried out, could remain secret.

"Some of it we will do in a way that they will know, but not everybody will," he said.

Clinton attacks Putin

Obama made his comments at an annual end-of-year news conference, one tinged with melancholy at the impending end of his presidency, foreboding about the changes that could follow President-elect Donald Trump into office next month, and uneasiness about the role Russia played in the political earthquake that has resulted from his election.

The president spoke hours after Hillary Clinton, addressing campaign donors in New York, bluntly accused President Vladimir Putin of Russia of orchestrating the hacks against her campaign and the Democratic National Committee "to undermine our democracy," as part of a "personal beef against me."

Obama declined to place the blame for the hacking so squarely on Putin, though he noted, "Not much happens in Russia without Vladimir Putin." Obama also sought to diminish the specter of Russian influence over the U.S. political process, saying Russia was a smaller, weaker country that "doesn't produce anything that anybody wants to buy, except oil and gas and arms."

Still, the president was wrestling with what he said the hacking affair and the reaction to it revealed about the state of U.S. politics. Citing a recent poll that showed more than a third of Trump voters saying they approved of Putin - "Ronald Reagan would roll over in his grave," Obama said - the president appealed to Americans not to allow partisan hatred and feuds to blind them to manipulation by foreign powers.

"Unless that changes," Obama said, "we're going to continue to be vulnerable to foreign influence because we've lost track of what it is that we're about and what we stand for."

Cautionary tale

The president continued to defend his cautious approach to reports of hacking - an approach that has come under criticism from Democrats after it emerged last week that the intelligence agencies had concluded Russia was trying to help Trump win the election.

"We were playing this thing straight - we weren't trying to advantage one side or the other," Obama said. "Imagine if we had done the opposite. It would have become one more political scrum."

Obama also made an admission as he described how his administration had reacted to the Russian hack: He said it was not until the "beginning of the summer" that the White House was "alerted to the possibility that the DNC has been hacked."

That was nine months after an FBI agent had first contacted the Democratic National Committee with evidence a major, government-linked hacking group was inside the committee's networks, raising the question of why it took so long for that news to reach the president.

Obama made it clear he went out of his way to play down the news, because "in this hyperpartisan atmosphere" he did not think he or anyone else at the White House could talk about it without risking to appear to be acting on behalf of Clinton.

September warning to Putin

But the unintended result, as some of Obama aides concede, was that the Russians faced little resistance. Not until September, when Obama pulled Putin aside at a Group of 20 meeting in Hanghzhou, China, was the Russian leader given a warning from the U.S. Obama said he told him "to cut it out, there were going to be serious consequences if he did not."

The president made it sound like that worked, saying "we did not see further tampering of the election process."

But the leaks of DNC emails, and those of John Podesta, the Clinton campaign manager, continued, because they were in the hands of WikiLeaks, which doled them out to an eager news media until the last days of the campaign.

The Russian government's motives were hardly a mystery, Obama said, "because you guys wrote about it every day, every single leak about every little juicy piece of political gossip, including John Podesta's risotto recipe."