Four US forces have been killed in an attack on Bagram Air Base in Afghanistan, a US official said tonight, speaking on condition of anonymity.

The attack comes as the United States prepares for talks this week with the Taliban.

The official said insurgents attacked the base with some kind of indirect fire, leaving open the possibility it was hit by rockets or mortar rounds.

No further details were immediately available.

Earlier, it was announced that the US will meet the Taliban for talks aimed at achieving peace in Afghanistan.

The US and the insurgent group have fought a bloody and costly war in the nation for the past 12 years.

The Taliban opened an office in Doha, the Qatari capital, to help restart talks and said it wanted a political solution that would bring about a just government and end foreign occupation of Afghanistan.

A senior US official said the talks would start in Doha on Thursday, but US President Barack Obama cautioned against expectations of quick progress.

He said the peace process would not be easy or quick.

US officials say they hope this week's talks will pave the way for the first ever official peace negotiations between the government of Afghan President Hamid Karzai and the Taliban.

The group has waged a 12-year insurgency to oust Mr Karzai's government and eject US-led NATO troops from the country.

US officials said the process could take many years and be subject to reversals.

"This is an important first step towards reconciliation; although it's a very early step," Mr Obama said after a G8 meeting in Enniskillen, Co Fermanagh.

"We anticipate there will be a lot of bumps in the road."

US officials said that in the talks in Doha, the United States would stick to its insistence that the Taliban break ties with al-Qaeda, end violence, and accept the Afghan constitution, including protection for women and minorities.

US officials said it would be the first US meeting with the Taliban in several years.

It was expected to involve an exchange of agendas, followed by another meeting a week or two later to discuss next steps.

A US official said he expected the initial meeting would be followed within days by another between the Taliban and the High Peace Council, a structure set up by Mr Karzai to represent Afghanistan in such talks.

A senior Afghan official said the Taliban had held secret discussions with the Afghan government and was willing to consider talks involving the High Peace Council.

The Taliban has until now said it would not countenance peace talks with the Karzai government, which it considers a puppet of the United States and other Western nations.

No dates agreed for talks - Taliban

In opening the Qatar office, the Taliban said it sought a political solution, but said no dates had been agreed for talks.

"There are no scheduled dates," Tayeb Agha, a former chief of staff to the Taliban's reclusive leader, Mullah Mohammed Omar, said in remarks carried live on al Jazeera television.

Another Taliban representative, Mohammed Naeem, told a news conference at the opening of the Doha office that the Islamist group wanted good ties with foreign countries.

"We want to keep good relations with all of the world countries, in particular with our neighbouring countries," he said. "But the Islamic emirate [Taliban] sees the independence of the nation from the current occupation as a national and religious obligation."

The US officials, who spoke on condition of anonymity, said the level of trust between the Afghan government and the Taliban was low, and played down expectations that the talks would quickly lead to peace.

"We need to be realistic," said one official. "This is a new development, a potentially significant development. But peace is not at hand."

News of the planned talks comes as the United States and its allies in NATO seek to meet a deadline of the end of next year for an end to foreign combat operations in Afghanistan.

This would allow them to withdraw the majority of their troops and wind down an engagement launched after the 9/11 attacks on the United States in 2001 that has cost hundreds of billions of dollars and tens of thousands of lives.

Mr Obama said peace would only come through an Afghanistan-led process, and commended Mr Karzai for taking a courageous step toward peace.

He stressed that the US military effort would continue in spite of the peace efforts.

"We don't anticipate this process will be easy or quick but we must pursue it in parallel with our military approach. And we in the meantime remain fully committed to our military efforts to defeat al-Qaeda and to support the Afghan national security forces," Mr Obama said.

Despite the accompanying words of caution, the announcement of the planned talks does represent a significant step forward in the peace process, which has struggled to achieve results despite years of attempts.

A team of envoys from the Taliban flew to Qatar in early 2012 to open talks with the US government.

But the Taliban suspended the talks in March 2012, saying the US was giving mixed signals on the nascent Afghan reconciliation process.

Mr Karzai, speaking this evening as the US-led NATO coalition launched a final phase of security transfers to Afghan forces, said his government would send a team to Qatar, but said the talks should quickly be moved to Afghanistan.

"We hope that our brothers the Taliban also understand that the process will move to our country soon," Mr Karzai said.