WASHINGTON — A Defense Department inquiry into potentially inappropriate emails between the U.S. commander in Afghanistan and a socialite in Tampa, Fla., has cleared the officer, Gen. John Allen, of wrongdoing, senior officials disclosed Tuesday.

The Pentagon inspector general wrote to Allen that the investigation had found no improprieties in the email communications with the socialite, Jill Kelley, officials said.

Allen maintained all along that he had done nothing wrong, and his supporters said the emails had neither violated security nor represented an improper relationship with Kelley, who frequently hosted social events for senior officers at the military’s Central Command headquarters in Tampa.

But the number of emails, and what some feared was inappropriate tone or language in the messages, prompted the probe.

    Most Read Stories

The emails had been uncovered as part of the discovery of an extramarital affair that ended the public career of David Petraeus, who then was in charge of the CIA. The FBI discovered the emails during an investigation into anonymous emails to Kelley warning her to stay away from Petraeus. The FBI found the emails had been sent by Paula Broadwell, Petraeus’ biographer. Petraeus admitted to having had an affair with Broadwell and resigned his position Nov. 9.

Like Allen, Petraeus, a retired four-star general, was a social acquaintance of Kelley’s when he was stationed at MacDill Air Force Base in Tampa, Fla.

Although the exact content of the emails remains unknown, an official conclusion of no wrongdoing will no doubt be seen as a professional and personal exoneration for Allen after an embarrassing period near the end of a highly respected Marine Corps career.

What remains unknown is the fate of Allen’s nomination to become the top NATO commander, as was planned before the emails were disclosed. Allen could be nominated to that position or another senior post or he could retire.

Pentagon officials described the voluminous correspondence between Allen and Kelley as potentially “inappropriate communication.” Law-enforcement officials say the emails number in the hundreds and cover 2½ years starting in 2010, when Allen was the deputy commander of Central Command.

The FBI sent the emails between Allen and Kelley to the Pentagon on Nov. 11.

Investigators looked into whether the emails violated Defense Department policy, government regulations or military law. At issue was whether the emails contained inappropriate language that was on a government computer; whether they indicated an inappropriate relationship as defined under military law; whether they involved more than an incidental use of government property for personal matters; and whether there were security breaches.