Indonesian presidential candidates Prabowo Subianto, at left, and Joko Widodo shake hands during a televised debate Sunday in Jakarta, Indonesia. The country is scheduled to hold its presidential election July 9. Associated Press

JAKARTA, Indonesia—The country's presidential candidates struck nationalistic tones in their third debate Sunday night, hoping to sway voters amid an increasingly tight race just weeks before elections in the world's third-largest democracy.

Former army general Prabowo Subianto and Jakarta Gov. Joko Widodo both stressed the need to strengthen the military, better protect the archipelago nation's maritime borders and take care of millions of overseas migrant workers while maintaining cordial but assertive relations with close neighbors such as Australia.

A nationalistic refrain was expected for the night, given topics of national security and international relations and the appeal of such rhetoric to voters, who head to the polls July 9, analysts said. Rising resource nationalism in recent years has given rise to regulations limiting foreign investment and activity that are popular across party lines in the trillion-dollar economy.

The two men took different approaches, however. Mr. Widodo showed his breadth of understanding of a variety of issues, while Mr. Subianto repeatedly hit on a theme that Indonesia is losing money to exploiters of natural resources. He brought back many points to the idea that national security depends on social welfare.

"Too much of our assets have been taken outside Indonesia," Mr. Subianto said. "We export bauxite, and then import aluminum. That is a leakage."

"The biggest threat coming from the domestic front is poverty and the lack of control by Indonesia of its assets," he added.

Mr. Widodo came into the night as the slight front-runner in the race but the underdog in the debate, lacking Mr. Subianto's military experience or his international education pedigree. Mr. Widodo has spent the majority of his political career governing a midsize city in central Java but has risen rapidly on a promise to bring a new style of pragmatic leadership to Southeast Asia's largest economy.

In the debate, he surprised many observers, speaking in detail about protections for overseas workers, saying that ambassadors must be "80% marketers" and positioning Indonesia's resource-rich waters as a global maritime axis. He consistently stressed that diplomacy would be the way of his presidency.

He also tried to portray himself as a firm leader, addressing a concern among voters that he lacks the authority of Mr. Subianto, who served in the military under the late authoritarian leader Suharto.

"Don't think I'm not firm. 'Firm' for me is to dare to make decisions and take risks," Mr. Widodo said. "When it comes to sovereignty, I will do whatever it takes."

Mr. Subianto, who surprised many analysts by not playing up his military background, was the more strident of the two in terms of nationalism.

"We can yell all we want, but can we defend our national interests? That is the main thing," he said. "If we are strong, we will have bargaining power."

But he also gave a nod to current President Susilo Bambang Yudhoyono, saying he had led Indonesia on the right track and kept peace in the country for a decade. Several times, he repeated a catch phrase made popular by Mr. Yudhoyono: "One thousand friends too few, one enemy too many."

Both men said they would try to build trust with Australia in the wake of a phone-tapping scandal that has frayed ties between the two neighbors.

Analysts said the debate was unlikely to sway the opinion of the majority of Indonesians who have already chosen camps.

"Those who like Prabowo will have loved his performance tonight. Those inclined to Jokowi will have been pleased with his general competence overall in an area everyone knows is not his specialty and a few very strong answers," said Doug Ramage, an analyst with BowerGroupAsia in Jakarta. "It reinforces the current trajectory of the race."

Marcus Mietzner of Australian National University said, "Overall, I suspect Indonesians will view Prabowo as the winner of this debate. He spoke more fluently and was able to insert some of his famous demagoguery—i.e., the references to foreign countries benefiting from Indonesia's natural resources."

"Jokowi took a long time to warm up and had very few memorable lines," he said. "But given how badly many observers thought he would do, he came out of this honorably."

—I Made Sentana in Jakarta contributed to this article.

Write to Ben Otto at and Andreas Ismar at