Obama, who is the keynote speaker Wednesday at the Democratic National Convention, was asked in an interview with NBC's Today Show whether Republican candidate Donald Trump could defeat the Democrat's Hillary Clinton .
"Anything is possible," he said.
"As somebody who has now been in elected office at various levels for about 20 years, I have seen all kinds of crazy stuff happen, and I think everybody that goes into campaigns not running scared can end up losing.
"My advice to Democrats -- I don't have to give this advice to Hillary Clinton because she already knows it -- is you stay worried until all the votes are cast and counted, because one of the dangers in an election like this is that people don't take the challenge seriously, they stay home, and we end up getting something else."
Clinton was proclaimed the Democratic presidential nominee Tuesday night at a star-studded convention in Philadelphia keynoted by husband and former president Bill Clinton.
Divisions were on display, however, after leaked emails showed that leaders of the supposedly neutral Democratic National Committee worked to undermine the candidacy of Clinton primary rival, Bernie Sanders.
The Clinton campaign has blamed the leak on Russian hackers bent on helping the Trump campaign. The FBI has said it is investigating.
"Anything is possible," Obama said when asked in the interview about the hack.
"Donald Trump has repeatedly expressed admiration for Vladimir Putin," Obama said in an excerpt of the interview that aired earlier.
"And I think that Trump's gotten pretty favorable coverage back in Russia."
Obama praised Clinton as an "outstanding secretary of state" who helped make the country safer and defended her against Republican accusations that her use of a private email account while in office had compromised national security.
"What I think is scary is a president who doesn't know their stuff and doesn't seem to have an interest in learning what they don't know," he said, referring to Trump.
"I think if you listen to any press conference he has given or any debates, basic knowledge about the world or what a nuclear triad is, or the difference between Sunni and Shia in the Muslim world, those are things he doesn't know and hasn't seem to spend a lot of time trying to find out about."
Obama, who speaks to the convention Wednesday night, said his message would be that "the president of the United States is profoundly optimistic about America's future, and is 100% convinced that Hillary Clinton can be a great president."