KABUL (Reuters) - Afghanistan inaugurated its first new president in a decade on Monday, swearing in technocrat Ashraf Ghani to head a power-sharing government just as the withdrawal of most foreign troops presents a crucial test.

The first democratic handover of power in Afghan history has been far from smooth: the deal for a unity government was cobbled together after months of deadlock over a vote in which both Ghani and opponent Abdullah Abdullah claimed victory.

Illustrating the problems facing the new president, a suicide bomber killed seven people at a security checkpoint near Kabul airport just before Ghani was sworn in, a government official said. The Taliban claimed responsibility.

Later, ending months of uncertainty over the future U.S. role in Afghanistan, the U.S. embassy announced Ghani would on Tuesday send a representative to sign a security agreement with the United States allowing a small continent of troops to remain.

In his inaugural speech, Ghani appealed to the Taliban and other militants to join peace talks and put an end to more than a decade of violence. Thousands of Afghans are killed each year in the insurgency.

“Security is a main demand of our people, and we are tired of this war,” Ghani said. “I am calling on the Taliban and Hezb-i-Islami to prepare for political negotiations.”

Hezb-i-Islami is an Islamist faction loosely allied with the Taliban.

Ghani also vowed to crack down on rampant corruption and called for cooperation within the coalition government.

“A national unity government is not about sharing power, but about working together,” Ghani said in his speech that lasted for nearly an hour.

Slideshow ( 4 images )

But signs of tension are already appearing in the fragile coalition. A dispute over office space and whether Abdullah would speak at the inauguration led to threats his camp would boycott Monday’s ceremony, an Abdullah aide said, adding it was resolved after late-night meetings with the U.S. ambassador.

The inauguration marks the end of an era with the departure of President Hamid Karzai, the only leader Afghans have known since a U.S.-led invasion in 2001 overthrew the Islamist Taliban who had given sanctuary to al Qaeda.

Ghani’s first act after being sworn in was to sign a decree creating the post of chief executive. Abdullah was sworn in to that job moments later, and he made a speech before Ghani - a departure from the original programme. The specially created post carries powers similar to those of a prime minister.

Both foreign backers and Afghans hope that Ghani and Abdullah can put aside their acrimonious election rivalry and work to improve life in a country that has suffered war and poverty for decades.

Even if its top figures can work together, the government inherits massive problems, including fighting an emboldened Taliban who in recent months has been launching ever-more aggressive attacks as foreign troops draw down.

GOVERNMENT BROKE

Monday’s suicide bombing in Kabul killed four members of the security forces and three civilian passers-by, Interior Ministry spokesman Sediq Sediqi said. Taliban spokesman Zabihullah Mujadid said the bomber was targeting Afghan and foreign forces.

Also on Monday, four suicide attackers killed eight people near a government office in the eastern province of Paktia, said police official Azimullah, who uses just one name.

Slideshow ( 4 images )

Ghani must also reset relations with the United States, which have soured in recent years under Karzai.

One of the new government’s first acts will be signing the bilateral agreement to allow some U.S. forces to remain in the country to train and help the Afghan army and police, and for the United States to keep some military bases. About 10,000 U.S. troops are expected to stay on.

U.S. Ambassador James Cunningham said a representative of Ghani would sign the deal early on Tuesday at the presidential palace in Kabul. Karzai had refused to sign the agreement, but both Ghani and Abdullah have said they are in favour of endorsing it promptly.

The inauguration ceremony was held at the vast presidential palace compound in central Kabul. Foreign dignitaries including Pakistani President Mamnoon Hussain and senior White House adviser John Podesta were due to attend.

The new government will immediately face a fiscal crisis. Already heavily dependent on foreign aid, Kabul has asked the United States and other donors for $537 million to pay its bills until the end of the year.

A Finance Ministry official acknowledged over the weekend that the government was so broke it had been forced to delay paying civil servants’ salaries for October because the treasury did not have the $116 million needed.

Some hope that Ghani, a longtime World Bank official and former finance minister, will put his knowledge of international institutions and development to work in combating Afghanistan’s tradition of corrupt and inefficient government.

A U.S.-trained anthropologist from Afghanistan’s Pashtun ethnic group, Ghani spent almost a quarter of a century outside Afghanistan during its tumultuous decades of 1980s Soviet occupation, followed by civil war and Taliban rule.

After the Sept. 11 attacks, he returned to become a senior adviser to Karzai.

Abdullah stayed in Afghanistan during the years of war as a close confidant to the anti-Soviet and later anti-Taliban fighter Ahmad Shah Massoud, an ethnic Tajik commander who was assassinated in 2001. Abdullah later served as foreign minister.

If he and Ghani can work together well, they could help bridge longstanding ethnic and political divides, although sceptics fear the coalition will inevitably be caught up in power struggles and rivalries between entrenched interests.

White House counselor John Podesta, who represented President Barack Obama at the inauguration, acknowledged the challenges facing the new government but said Ghani and Abdullah they are “both strong, committed leaders” who he believed would put their country before personal ambition.

“We’re optimistic that this not only can work, but will work,” Podesta told reporters on Monday in Kabul.