The Pentagon has cleared the top US commander in Afghanistan of wrongdoing over emails with a woman tied to the sex scandal that forced CIA director David Petraeus to resign, a US official said. The Defence Department's inspector general completely exonerated General John Allen, the outgoing chief of US-led forces in Afghanistan, over the emails, paving the way for his pending nomination to take up command of NATO forces in Europe, the official said. "Allen has been cleared by the IG," the official told AFP on condition of anonymity. The FBI came upon the emails from Allen in its probe of Petraeus, and defence officials had said the tone of the messages had been potentially "inappropriate" and possibly violated rules applying to military officers. Allen had exchanged messages with Jill Kelley, a Florida socialite who had thrown parties for senior officers at US Central Command, which has its headquarters in Tampa. Kelley had alerted the FBI to anonymous emails she received and claimed were threatening. The emails were traced to David Petraeus's biographer, Paula Broadwell, and authorities then uncovered evidence that Broadwell was having an affair with the CIA director.  The scandal prompted Petraeus to resign abruptly in November from his CIA post, ending a storied career marked by his tenure as military commander in the wars in Iraq and Afghanistan. But the FBI also found numerous emails between Allen and Kelley, and Defense Secretary Leon Panetta ordered an independent inquiry by the Pentagon inspector general. Panetta "was pleased to learn that allegations of professional misconduct were not substantiated by the investigation," and has "complete confidence" in Allen's leadership, his spokesman George Little said in a statement. Initially, officials had said there were 25,000 to 30,000 pages of correspondence between Allen and Kelley, raising questions that his emails could reflect a distracted commander. But officials later said the inquiry was only focused on a few hundred messages.