US President Barack Obama has said Republican Donald Trump's insistence that he might not accept the election result is "dangerous".
Trump's comments undermined American democracy, BBC quoted the President as saying at a campaign rally in Miami for Democratic nominee Hillary Clinton.
Trump refused in a televised debate to say he would accept the outcome of the election on November 8.
He later said he would accept a "clear" result but left a challenge open.
Speaking in Ohio on Thursday, Trump said, with a grin: "I would like to promise and pledge to all of my voters and supporters and to all of the people of the United States, that I will totally accept the results of this great and historic presidential election - if I win."
In the same speech, he said he would accept a clear election result but reserved the right to file a legal challenge in the case of a questionable one.
Hours later, the President said that sowing the seeds of doubt in people's minds about the legitimacy of US elections provided a boost to the country's enemies.
"You're doing the work of our adversaries for them, because our democracy depends on people knowing that their vote matters," BBC quoted Obama as saying.
For days, Trump has claimed the election is rigged against him, due to media bias and voter fraud.
During Wednesday night's debate with Clinton, when moderator Chris Wallace asked Trump if he would accept losing to her, the Republican candidate said he would "keep you in suspense".
Trump's campaign manager, Kellyanne Conway, later insisted that the candidate had meant he would not concede until the "results are actually known".
Republican Senator John McCain, who lost to Obama eight years ago, said: "A concession isn't just an exercise in graciousness. It is an act of respect for the will of the American people, a respect that is every American leader's first responsibility."
First Lady Michelle Obama also joined the attack on Thursday, saying "you do not keep American democracy in suspense".