Updated

Hamid Karzai (search) was sworn in Tuesday as Afghanistan's first popularly elected president, calling for sustained help from the international community to bolster a young democracy that still faces the twin threats of terrorism and drugs.

The U.S.-backed leader, wearing a traditional green robe and a black lambskin hat, took the oath of office in a solemn ceremony in a restored hall of the war-damaged former royal palace.

Vice President Dick Cheney (search), the highest-ranking American official to visit Afghanistan since the fall of the Taliban (search) in 2001, and Secretary of Defense Donald Rumsfeld (search) were among those who gave Karzai a standing ovation when he arrived.

Karzai repeated the oath of allegiance read to him by Afghanistan's white-bearded chief justice, Fazl Hadi Shinwari. He then swore in his two vice presidents, Ahmad Zia Massood and Karim Khalili, members of the country's two largest ethnic minorities.

Kabul was calm amid massive security for the ceremony, but overnight attacks near the Pakistani frontier that left 12 dead provided a strong reminder of threats to the nation's stability.

In his inaugural address, Karzai said the hopes of ordinary Afghans would drive him during what is likely to be a tough five-year term. He reiterated his main pledges — cracking down on the booming opium trade, disarming militias and lifting living standards.

"We have now left a hard and dark past behind us and today we are opening a new chapter in our history in a spirit of friendship with the international community," Karzai said, speaking in Pashto and Dari, Afghanistan's two main languages.

He said the fight against terrorism was "not yet over" and urged continued international aid and cooperation to defeat increasing links between extremists and drug-trafficking.

"The same cooperation has led to the rebuilding of the Afghan state and significant progress in restoring peace, stability and security to our country."

Wary of attacks by Taliban or Al Qaeda militants, Afghan and international forces launched their biggest security operation since the Oct. 9 election that gave Karzai, who had been interim leader, a landslide victory.

Hours before the ceremony, dozens of insurgents armed with assault rifles and rockets attacked an Afghan military base in Khost province, sparking a firefight that left four Afghan soldiers and at least six militants dead, an Afghan commander said.

Also in Khost, insurgents opened fire on a U.S. patrol, which returned fire and killed two of the assailants, U.S. spokesman Maj. Mark McCann said. No Americans were reported hurt.

Militants also tried to launch a rocket toward Kabul on Monday evening, but it landed harmlessly on a cattle farm outside the city limits, a NATO spokesman said.

Cheney, arriving at the main U.S. base north of Kabul earlier Tuesday, congratulated some of the 18,000 U.S. troops here for helping give democracy a chance to take root.

"For the first time the people of this country are looking confident about the future of freedom and peace," Cheney said. "Freedom still has enemies here in Afghanistan, and you are here to make those enemies miserable."

The establishment of a democracy in Kabul was necessary to Afghanistan's "basic, fundamental transformation," Cheney said later, speaking on NBC's "Today" show.

"It has to happen, if you will, if we're going to win the war on terrorism," Cheney added. Democracies give rise to people who "are focused on their own lives and focused on building a free society," he said.

Before the ceremony, Karzai thanked the United States, his main sponsor, for its help.

"Without that help, Afghanistan would be in the hands of terrorists," he said. "Terrorism as a force is gone. As individuals they are all around and we will continue to look for them."

The list of 150 foreign dignitaries included Iranian Foreign Minister Kamal Kharrazi and Pakistan's Interior Minister, Aftab Khan Sherpao. Lakhdar Brahimi, special adviser to U.N. Secretary-General Kofi Annan, represented the world body.

Rumsfeld cautioned that the military mission here is not over.

"There are still groups, extremists, that would like to take this country back — the Taliban, the Al Qaeda — and use it for a base for terrorist activities around the world as they did on 9/11," Rumsfeld told a group of special forces soldiers at Bagram. "But it's not going to happen."

Annan has warned in a report to the U.N. Security Council that unless Karzai tackles Afghanistan's surge in opium production and its arms proliferation, much of its recent progress could be seriously undermined and "the economy may well be subsumed by the illicit drugs industry."

The inauguration was the culmination of a three-year drive to transform Afghanistan from a training ground for Al Qaeda extremists into a moderate Islamic republic.

Afghans have adopted a new constitution labeled by the United States as the most progressive in the region and held their first Western-style vote, despite militant attacks that killed at least 15 election workers.

Some 3 million Afghan refugees displaced by more than two decades of warfare have returned home, and women and girls are back in jobs and schools from which they were barred under the previous regime. The economy is growing strongly.

But insurgents continue to harass U.S. and Afghan forces across a broad swath of the south and east. American officials expect to keep their force strength at about 18,000 at least until after parliamentary elections slated for the spring.

Karzai has said the drug economy, which now accounts for an estimated one-third of national income, is a bigger threat than the insurgents and will be the top priority for the coming years.

U.N. surveys show cultivation of opium poppy in Afghanistan, from which most of the world's heroin is refined, jumped more than 60 percent this year, and warn that drug smuggling mafias are taking an iron grip on the country.