A prominent Christian ally of Mr. Joko, the former Jakarta governor Basuki Tjahaja Purnama, who is of Chinese descent, was imprisoned for blasphemy last year after hard-line Islamic groups mounted a protest campaign against him. Those groups — some of which are allied with Mr. Prabowo’s opposition Gerindra party — are likely to turn their sights on the president as the election approaches, some analysts said.

“They will be looking around for sure to pick up on some religious-based scandal,” said Stephen Sherlock, a professor of politics at the University of New South Wales who studies Indonesia.

Mr. Joko, 57, who was born in a slum in Central Java Province and sold furniture before becoming a popular Jakarta governor, won the presidency in 2014 with 53 percent of the vote, campaigning as a political outsider. Reputable opinion polls during the past year have consistently put his approval rating above 50 percent, sometimes as high as 70 percent, and he is largely seen as having lived up to his promises to fight corruption and improve the country’s infrastructure, starting large toll road, airport and seaport projects.

“What we have been doing is four years of proof — and proof is not fiction,” Mr. Joko said Friday at the office of the General Elections Commission in Jakarta after submitting the paperwork declaring his intent to run. “This is the foundation that has been built, that still needs to be connected, that still needs to be continued.”

Recent surveys have put the president far ahead of Mr. Prabowo, by margins of 15 to 20 percentage points. But Mr. Basuki, the president’s now-jailed ally, also had a double-digit poll lead in his campaign for re-election as Jakarta’s governor before Islamic groups began campaigning against him in earnest.