Former General Prabowo Subianto claimed that he had won and that his camp had evidence of "widespread cheating."
Official results will only appear in May, but "quick counts" by opinion polls have given Mr. Widodo a lead of about 10 percentage points.
The authorities have appealed to the peace and have promised to deal with any unrest.
"If there are illegal or unconstitutional actions that threaten public stability and security, [the authorities] will take strong action," said National Police Chief Tito Karnavian.
Wednesday's election in the world's third-largest democracy followed a bitter campaign in which religion played a key role.
Indonesia, a huge archipelago, is home to the world's largest Muslim population and has more than 260 million people.
More than 192 million were eligible to cast their vote to select 20,000 local and national legislators, including the president.
On Thursday, Mr Widodo told a press conference that he had won the vote by 54.5% - based on counts by 12 students. Leaders from more than 20 countries had already called to congratulate him, he said.
Mr Widodo also said that the quick counts of the sample votes were very accurate and that the country had to wait "patiently" for official results.
A few minutes later, Mr Prabowo told reporters that his camp announced the victory because it "had evidence of widespread cheating at the village, sub-district and district level throughout Indonesia". He said he had won with 62% of the votes.
At the last elections in 2014, Mr. Prabowo also challenged the results, claimed widespread fraud and declared victory after losing to Mr. Widodo. The Constitutional Court confirmed the result after rejecting its legal challenge.
Indonesian stocks grew on Thursday morning when investors responded to the expectation that Mr. Widodo had won a second five-year term.
Official results will only appear in May, but "quick counts" by opinion polls have given Mr. Widodo a lead of about 10 percentage points.
The authorities have appealed to the peace and have promised to deal with any unrest.
"If there are illegal or unconstitutional actions that threaten public stability and security, [the authorities] will take strong action," said National Police Chief Tito Karnavian.
Wednesday's election in the world's third-largest democracy followed a bitter campaign in which religion played a key role.
Indonesia, a huge archipelago, is home to the world's largest Muslim population and has more than 260 million people.
More than 192 million were eligible to cast their vote to select 20,000 local and national legislators, including the president.
On Thursday, Mr Widodo told a press conference that he had won the vote by 54.5% - based on counts by 12 students. Leaders from more than 20 countries had already called to congratulate him, he said.
Mr Widodo also said that the quick counts of the sample votes were very accurate and that the country had to wait "patiently" for official results.
A few minutes later, Mr Prabowo told reporters that his camp announced the victory because it "had evidence of widespread cheating at the village, sub-district and district level throughout Indonesia". He said he had won with 62% of the votes.
At the last elections in 2014, Mr. Prabowo also challenged the results, claimed widespread fraud and declared victory after losing to Mr. Widodo. The Constitutional Court confirmed the result after rejecting its legal challenge.
Indonesian stocks grew on Thursday morning when investors responded to the expectation that Mr. Widodo had won a second five-year term.

ConversionConversion EmoticonEmoticon