WASHINGTON -- The Pentagon's inspector general has cleared the top U.S. commander in Afghanistan of wrongdoing after an investigation into whether he exchanged inappropriate emails with the same Florida socialite involved in the scandal that led David Petraeus to resign as CIA director, senior officials said.The FBI uncovered messages from Marine Gen. John Allen during its investigation of Petraeus last year. The tenor of some emails, which senior 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 officials, who spoke on the condition of anonymity because they were not authorized to discuss the matter."He was completely exonerated," one official said.Allen exchanged the messages with Jill Kelley, 37, who ingratiated herself with several senior officers at the Tampa, Fla., headquarters of the U.S. Central Command.Kelley's complaint to the FBI about another set of messages -- ones that were harassing -- eventually led to the discovery of an affair between Petraeus and his biographer, Paula Broadwell. The FBI determined that Broadwell, for reasons still not clear, had sent Kelley the harassing emails.A spokesman for Allen declined to comment.Overreaction?The inspector general's investigation prompted the White House to hold up Allen's nomination as supreme allied commander in Europe.Allen is scheduled to relinquish command in Afghanistan early next month, and the Pentagon has not yet requested that the Senate Armed Services Committee reschedule his nomination.Defense officials have said Panetta's decision to refer the emails to the inspector general was driven by the content of some messages and by a desire to show that the Pentagon is not trying to ignore any potential misconduct after the Petraeus scandal.Although the messages have not been released, and the inspector did not characterize them in the letter, some military officials sympathetic to Allen questioned Tuesday whether Panetta had overreacted, placing a cloud over the general's head at a crucial juncture in the Afghan war.A senior defense official said Panetta referred the matter to the inspector general on the recommendation of civilian and military attorneys.Allen has spent the past few weeks refining his recommendations for the number of U.S. troops who should be withdrawn from Afghanistan this year and the number who should be stationed there once the U.S. and NATO combat mission ends in 2014.Senior military and administration officials expect Allen's preferred options, which have not been formally submitted, to entail more troops than those favored by top civilian aides to President Barack Obama. Allen wants to keep about 9,000 troops in Afghanistan after 2014, while White House officials are leaning toward 2,500 to 6,000, those officials said.Although initial reports described the volume of messages between Allen and Kelley as totaling 20,000 to 30,000 printed pages, the two exchanged only a few hundred messages over multiple years, one of the U.S. officials said."Some of the messages are not the sort of things you would print in a family newspaper," the official said. "But that doesn't mean he violated military regulations by sending and receiving them."'Sign of politeness'Officials close to Allen have long insisted that he did not have a sexual relationship with Kelley. Allen's supporters said Kelley was a close friend to Allen and his wife, Kathy.Many of the messages related to social events or to items that Kelley had seen in the news, said a senior official close to Allen. Sometimes she wrote to compliment the general on a television interview, the official said, and sometimes she copied him on a message intended for his wife. "He returns almost every email," the official said soon after the investigation commenced. "To him, it's a sign of politeness."The frequency of Allen's communication with Kelley raised questions about whether his focus on the war was compromised.But Allen's aides said he generally reads and responds to personal email between midnight and 2 a.m., after most of his subordinates have gone to bed.