General Raheel Sharif on Friday formally took over as the head of Pakistan's army, the most powerful position in the troubled military-dominated nation which is battling a homegrown Taliban insurgency.Sharif, named chief of the army staff on Wednesday, took charge from predecessor General Ashfaq Kayani at a ceremony at military headquarters in Rawalpindi.He takes over as head of the nuclear-armed state's 600,000-strong army with a daunting array of challenges ahead of him.The country is struggling with the Taliban campaign which has claimed thousands of lives, vexed relations with India and the winding-down of the 12-year NATO mission in neighbouring Afghanistan.Sharif, a veteran infantry commander, was little known outside military circles before his promotion to army chief, but analysts say he is a dedicated soldier with little interest in politics.Prime Minister Nawaz Sharif passed over two more senior generals to appoint his namesake, who is no relation, and will be hoping to avoid a repeat of events the last time he named an army chief -- General Pervez Musharraf overthrew him in a coup in 1999.Pakistan has seen three coups and been ruled for more than half its 66-year history by the military. The armed forces still retain a powerful influence.Departing commander Kayani has served as army chief since 2007 and has been given much credit for resisting the temptation to meddle overtly in politics.His command saw Pakistan's first ever transition of power from one democractically elected government to another at May's general election.When he confirmed his retirement last month he stressed that the armed forces "fully support and want to strengthen" democracy.'Biggest sacrifice'His tenure has been marked by the bloody fight against the Pakistani Taliban, who have killed thousands in their battle against the state.Many of the dead have been soldiers, killed and sometimes even beheaded by militants in clashes in the country's northwest.In his valedictory speech on Friday, Kayani paid tribute to the soldiers who had died fighting what he called the "internal threat"."The biggest sacrifice is that of one's life and the army has always been ready to lay down their lives for the country throughout history," he said."There is no place in any part of the country where there is no tomb of our martyrs, but in the last decade there has been a rapid increase in the number of these tombs."Under Kayani's command the army mounted successful offensives to wrest control of Swat district, in northwestern Khyber Pakhtunkhwa province, and South Waziristan tribal district from militants.But his tenure has also had its low points -- the military was humiliated by the 2011 US special forces raid to kill Osama bin Laden on the doorstep of its elite academy.The military's own bases have come under attack as never before, including an October 2009 militant siege of army headquarters in Rawalpindi in which 23 people were killed.The Taliban recently appointed hardline cleric Maulana Fazlullah as their new chief after his predecessor was killed by a US drone, raising fears of a new and bloody phase of the militants' insurgency.On Friday Kayani told the audience of troops and dignitaries in Rawalpindi that he had "kept the interests of the army, the country and the nation above everything" in his command.