The leaders of Indonesia and Britain have agreed to boost cooperation in the fight against terrorism during a visit by the British prime minister to Jakarta.

British Prime Minister Tony Blair pledged to work more closely with Indonesia, the nation with the world's largest Muslim population, to strengthen bilateral ties.

Mr. Blair met with Indonesian President Susilo Bambang Yudhoyno for an hour-long discussion and said both leaders agreed to strengthen cooperation against terrorism and expand defense ties.

"We want in defense terms now to treat Indonesia as it should be, as our friend and our ally," he said. "In respect of counter-terrorism, both our countries have suffered from terrorism, both have a common interest in defeating it and we are going to work closely together to do that."

Indonesia has suffered a spate of terrorist bombings over the past several years blamed on the regional terrorist network Jemaah Islamiyah. More than 200 Islamic extremists have been arrested for the bombings and several of them have been sentenced to death.

London was hit by bombings last July in two underground train stations and a bus that claimed 56 lives. Radical young British Muslims were blamed for the suicide attacks.

Indonesian President Yudhoyono says his government is working hard to prevent terrorist attacks, but says that extremism can be found in any country and must be dealt with in accordance with the law.

"In any country, in any society, in any religion, there are groups that are more radical, more extreme, more fundamental. And we have to deal with this group properly, wisely, justly," he said.

The leaders inaugurated the Indonesia-United Kingdom Islamic Advisory Group, composed of Muslim leaders from both nations aimed at promoting tolerance and countering extremism.

The British prime minister also met with five moderate Islamic leaders who urged him to withdraw British troops from Iraq.

Mr. Blair called the meeting with the Muslim leaders "inspiring and at times moving."

The prime minister took a grilling from students at an Islamic boarding school. They asked if he had tried to prevent the invasion of Iraq and told him to pressure Israel to bring peace to the Middle East.

His visit to Indonesia is the first by a British prime minister since 1985 and it is the last leg of a week-long tour that has taken him to Australia and New Zealand.