President-elect Donald J. Trump on Wednesday conceded for the first time that Russia had carried out cyberattacks against the two major political parties during the presidential election, but he angrily rejected unsubstantiated reports that Moscow had gathered compromising personal and financial information about him that could be used for extortion.

In a chaotic news conference in the lobby of Trump Tower in Manhattan nine days before he is to be sworn in as the nation’s 45th president, Mr. Trump compared United States intelligence officials to Nazis, sidestepped repeated questions about whether he or anyone in his presidential campaign had had contact with Russia during the campaign, and lashed out at the news media and political opponents, arguing that they were out to get him.

“As far as hacking, I think it was Russia,” Mr. Trump said, his first comments accepting the conclusions of United States intelligence officials that Moscow had interfered in the election to help him win. But the president-elect expressed little outrage about that breach and seemed to cast doubt on Russia’s role moments after acknowledging it, asserting that “it could have been others also.”

He also quoted a Kremlin denial Tuesday night of reports that it had gathered damaging information to compromise Mr. Trump. “They said it totally never happened,” Mr. Trump said of President Vladimir V. Putin of Russia and his government. “I respected the fact that he said that.”