The Pentagon's inspector general has cleared the top U.S. commander in Afghanistan of wrongdoing following an investigation into whether he exchanged inappropriate emails with the same Tampa, Florida, socialite involved in the scandal that prompted David Petraeus to resign as CIA director, senior U.S. officials said.

The FBI uncovered messages from Gen. John Allen during its investigation of Petraeus last year. The tenor of some of the emails, which defense officials described as racy and flirtatious, prompted Defense Secretary Leon Panetta to order a formal inquiry.

In a letter sent to Allen on Friday, the inspector general wrote that Allen had not violated military prohibitions against conduct unbecoming an officer, according to the senior U.S. officials. "He was completely exonerated," one of the officials said.