By Patricia Zengerle and Warren Strobel

WASHINGTON (Reuters) - FBI Director James Comey on Monday confirmed for the first time that the bureau is investigating possible ties between Republican Donald Trump's presidential campaign and Russia as Moscow sought to influence the 2016 U.S. election.

Comey and Admiral Mike Rogers, the director of the National Security Agency, made clear that their investigation of Moscow and November's U.S. elections could last for months.

Appearing before a congressional panel, Comey also publicly challenged Trump's claim that former President Barack Obama wiretapped his 2016 campaign headquarters in Manhattan's Trump Tower.

The two officials spent 5-1/2 hours before the House of Representatives Intelligence Committee in testimony marked by starkly partisan divides between the panel's majority Republicans and Democrats.

Comey refused to back away from his claim that Russian President Vladimir Putin did not simply want Democratic presidential candidate Hillary Clinton to lose the election; he wanted Donald Trump to win.

Trump created a controversy in early March when he tweeted without giving evidence that Obama had wiretapped his campaign while the businessman competed against Clinton.

"With respect to the president's tweets about alleged wiretapping directed at him by the prior administration, I have no information that supports those tweets," Comey said.

The committee is one of several in the U.S. Congress investigating whether Russia tried to influence the election, mostly by hacking Democratic operatives' emails and releasing embarrassing information. Russia denies the allegations.

Comey confirmed the FBI has been investigating since July possible Russian efforts to interfere in the election, including any cooperation between Trump's campaign and Moscow. He said that while the Russian government wanted to hurt Clinton's campaign and help Trump's, intelligence agencies made no judgment on whether the efforts influenced the outcome.

Story continues

Comey gave no details of the classified investigation and said the fact that it exists does not mean charges would be filed.

U.S. intelligence agencies have concluded that Russia tried to help Trump by hacking leading Democrats.

PUTIN'S PREFERENCE

"I think that was a fairly easy judgment for the (intelligence) community," he said. "Putin hated Secretary Clinton so much that the flip side of that coin was he had a clear preference for the person running against the person he hated so much."

Asked about Comey, White House spokesman Sean Spicer read a series of quotes from officials - some from the Obama administration - who have said they have seen no signs of collusion between Trump's campaign and Russia.

In a tweet before the hearing, Trump wrote: "The Democrats made up and pushed the Russian story as an excuse for running a

terrible campaign."

Spicer said he was unaware of any White House official being under investigation by the FBI.

Trump has frequently urged better relations with Russia, which has been at odds with the United States over Ukraine and the Syrian civil war.

Representative Adam Schiff, the top Democrat on the intelligence committee, detailed activities by Trump associates with ties to Russia, including former campaign manager Paul Manafort and Michael Flynn, who was forced out as Trump's national security adviser after talking to the Russian ambassador and then misrepresenting the conversation to Vice President Mike Pence.

"Is it possible that all of these events and reports are completely unrelated and nothing more than an entirely unhappy coincidence? Yes, it is possible," Schiff said. "But it is also possible, maybe more than possible, that they are not coincidental, not disconnected and not unrelated."

NO 'PHYSICAL' WIRETAP

Trump's March 4 tweet about wiretapping pulled attention away from the claims of Russian election interference. He issued his tweet two days after Attorney General Jeff Sessions, who met with Russia's U.S. ambassador at least twice last year, said he would recuse himself from any investigation of the matter.

The White House has contended in recent days that Trump's claim of wiretapping referred to general surveillance of the campaign. The White House has not provided evidence of surveillance of any kind.

"Let me be clear: We know there was not a physical wiretap on Trump Tower. However, it's still possible that other surveillance activities were used against President Trump and his associates," said Representative Devin Nunes, the committee's Republican chairman.

Last week, Trump's spokesman cited a media report that British intelligence was behind the surveillance, prompting ridicule in London.

Rogers said the allegation had strained relations with London. "I think it clearly frustrates a key ally of ours," Rogers said.

Comey warned that Russia would attempt to influence the next U.S. presidential election in 2020 and perhaps congressional elections next year.

"They'll be back in 2020. They may be back in 2018. And one of the lessons they may draw from this is that they were successful because they introduced chaos and division and discord and sowed doubt about the nature of this amazing country of ours and our democratic process," he said.

The rare open congressional intelligence committee hearing revealed a stark partisan divide. Republicans, who hold a majority of seats on the panel, largely concentrated their questions on leaks of classified information to the media - a concern that Trump frequently mentions.

Democrats sought to highlight links between the Republican's campaign and Moscow and to shoot down Trump's wiretapping claim.

(Additional reporting by Doina Chiacu; Writing by Alistair Bell and Patricia Zengerle; Editing by Bill Trott and Cynthia Osterman)