Islamic extremists must not be allowed to pervert fledgling democracies and persecute minorities, David Cameron has warned.
Delivering a speech in Indonesia, the Prime Minister praised the country as proof that the religion was compatible with democracy.
He insisted the shift away from authoritarianism made by the world's most populous Muslim state was an example to those caught up in the Arab Spring.
But Mr Cameron also highlighted the dangers facing new democracies such as Egypt, where Islamic political parties have significant support. "Let me be absolutely clear: I am not talking about Islam. Islam is a religion observed peacefully and devoutly by over a billion people," he told students at Al Azhar university in Jakarta.
"And let me also be clear: extremism is not only found among Muslims. But there is a problem across the globe with Islamist extremism which is a political ideology supported by a minority.
"Extremists - some of whom are violent - and all of whom want to impose a particular and very radical, extreme version of Islamism on society to the exclusion of all others. And this total rejection of debate and democratic consent means they believe that democracy and Islam are incompatible.
"What Indonesia shows is that in the world's largest Muslim-majority country, it is possible to reject this extremist threat and prove that democracy and Islam can flourish alongside each other. That's why what you are doing here is so important, because it gives heart to those around the world who are engaged in the same struggle."
Mr Cameron continued: "In Egypt, it is vitally important to ensure that the democratic success of the Muslim Brotherhood's party strengthens democracy and does not in the end undermine it. The choice of the Egyptian people must be respected and we must all be ready to work with the government that the Egyptian people elect."
Mr Cameron said Indonesia's decision to enshrine individuals' rights into its constitution reflected the "vital importance" of protecting minorities.
The speech came as the Prime Minister continued his trade mission in South East Asia, which started in Japan on Monday. He held talks with President Susilo Bambang Yudhoyono in Jakarta on Wednesday as part of efforts to deepen links with the fast-growing economy. But he suffered an embarrassing moment when his host suggested that boosting government spending and preventing companies laying off staff was the best way to fix a wrecked economy.