KABUL (AFP/Reuters) - Afghan lawmakers on Saturday endorsed a controversial new spymaster, accused of torturing detainees, and two other security chiefs who will likely play a key role as Kabul takes on increasing powers as Nato troops withdraw over the next two years.

President Hamid Karzai had last month nominated Asadullah Khalid, the outgoing borders and tribal affairs minister and two-time former provincial governor, to head the National Directorate of Security (NDS) despite strong criticism from Western human rights groups.

The nomination was part of a cabinet reshuffle, which has been interpreted as Karzai's effort to secure his powerbase before appointing a successor to stand for election in 2014.

Khalid, who is fiercely anti-Taliban and close to the Karzai family, secured a comfortable majority among the 241 lawmakers present, winning 143 votes -- well clear of the minimum threshold of 121 -- in an open vote broadcast live on state TV. It is expected that he will have to work closely with the CIA in his new position.

In a speech before the vote, Khalid promised a clean leadership but made no mention of the accusations against him.

"I will try to make the NDS a home for all Afghans. It will not be politicised and will remain impartial. There will be no toleration of those who are against the nation. We will foil terrorist activities in their sanctuaries," he said.

Parliament narrowly approved as defence minister the outgoing interior minister Bismillah Mohammadi with 124 votes, and his former deputy, Mujtaba Patang, as interior minister with 129 votes.

But Haji Din Mohammad, a former commander who fought against Soviet troops in the 1980s, failed to secure the requisite majority to become borders and tribal affairs minister.

Amnesty International had urged parliament to delay the vote, asking lawmakers to investigate claims of Khalid's "involvement in numerous alleged acts of torture and other grave human rights violations".

The London-based rights group said he has been linked to numerous cases of torture and unlawful killings over the past decade, while serving as governor of Ghazni province from 2001-05 and of Kandahar from 2005-08.

It also said there were credible allegations that Khalid was involved in the bombing of a vehicle that killed five UN workers in Kandahar in April 2007.

Karzai, who has led Afghanistan since the Taliban government was ousted in late 2001 by a US-led invasion, is under increasing domestic and international pressure to reform his administration.

His government has been widely criticised as being weak and corrupt, and for not being able to do more to reverse perceptions of declining security as Nato troops withdraw.

There have been numerous allegations of torture at prisons run by the NDS, denied by the intelligence service.

Analysts said the reshuffle was primarily about power ahead of a presidential election, expected in the next 18 months.

Parliament last month dismissed Mohammadi as interior minister and defence minister Abdul Rahim Wardak, allegedly for failing to stop a Taliban resurgence and cross-border shelling from Pakistan.

Wardak, who in particular had close relations with Western allies, has since been appointed senior presidential advisor.

"There is a team of mafia running this government. The same faces get reshuffled from post to post, this is very wrong," writer and political analyst Wahid Taqat told AFP.

"This (reshuffle) will give him (Karzai) political influence even after his term ends in 2014," he said.

Political turmoil has delayed decisions on crucial legislation, including a revised mining law being closely watched by Western donors and foreign mining companies.

Any fresh dispute between Karzai and parliament could also complicate the timetable for the planned transfer of security responsibilities to Afghan forces and a withdrawal by most foreign combat troops by 2014.

The human rights groups say the NDS has a long and well-documented history of torturing its detainees.

Diplomats and rights groups have linked Khalid to abuse of suspected insurgents at a prison in Kandahar during his time as provincial governor.

Some parliament members had said they wanted fresh appointments to come from outside Karzai's increasingly unpopular inner circle.

The approval of the majority of Karzai's appointments averted a deepening row, although one ministerial position remained vacant after the vote.

Haji din Mohammad, former governor of Kabul and close ally of the president, failed to win parliament's vote of confidence.

"We wish success to our winning ministers and ask President Karzai to appoint a new candidate as a minister of border affairs" said lower house speaker Abdul Rauf Ibrahimi.

New defence minister Mohammadi is an ethnic Tajik with a strong power base in the country's north, while NDS chief Khalid is an ethnic Pashtun with strong connections in the south, from where the Taliban draw most support.