Pakistan's President Pervez Musharraf has named his successor to take over as army chief, the military says.
Gen Kayani is army second in command for now
The appointee is former head of intelligence Gen Ashfaq Pervez Kayani, military spokesman Maj Gen Waheed Arshad told the BBC.
Gen Musharraf will resign as head of the army if he wins presidential elections on Saturday, his lawyers say.
Opposition parties say his candidacy is illegal and that he has broken previous promises to resign as army chief.
Gen Kayani has been appointed deputy chief of army staff and will take over the top post when it falls vacant, the military says.
It is not clear when that will be.
Gen Musharraf's lawyers told the Supreme Court last week that he would stand down as army chief "soon after election and before taking the oath of office as president".
Gen Kayani has taken part in recent secret talks on a possible power sharing deal between President Musharraf and former Prime Minister Benazir Bhutto.
His appointment came as current Prime Minister Shaukat Aziz met senior cabinet members to discuss measures which could see corruption charges against Ms Bhutto dropped.
Deputy Information Minister Tariq Azim said proposals to amnesty politicians who had been accused, but not convicted, of corruption in cases up to 1999 were in "the final stages".
"We hope that this ordinance may be promulgated as early as tomorrow," he told the Associated Press.
Gen Kayani headed Pakistan's notorious Inter-Services Intelligence agency from 2004 until last month.
06 Oct: Presidential vote to be held, election commission says
18 Oct: Date ex-PM Benazir Bhutto has set for her homecoming
15 Nov: Parliamentary term ends and general election must be held
The BBC's M Ilyas Khan in Karachi says he earned Gen Musharraf's confidence when he headed the investigation into two attempts on the president's life in December 2003, bringing a number of suspects to trial in a secret military court.
Gen Kayani's appointment will be closely watched in Washington which has been putting pressure on Pakistan to do more in the US-led "war on terror".
News of his promotion came as scores of opposition MPs resigned from Pakistan's national parliament and provincial assemblies in protest at Saturday's presidential election.
They insist that President Pervez Musharraf is ineligible to stand.
Correspondents say that the resignations make it even more certain that Gen Musharraf will win the vote.
Members who resigned from the assemblies on Tuesday were drawn mainly from an alliance of Islamic parties, the MMA, and the PML-N party of former Prime Minister Nawaz Sharif.
Gen Musharraf's election plans are illegal, critics say
Ms Bhutto's Pakistan People's Party (PPP), the country's biggest party, is not taking part in the boycott.
Meanwhile two rival candidates for Saturday's election have filed fresh petitions in the Supreme Court against Gen Musharraf's candidacy, saying he is not eligible to stand while also remaining head of the army.
Last Friday the court dismissed a number of petitions, in a move seen as a major victory for the president.
The president is elected by MPs from the national assembly and Pakistan's four provincial assemblies.