The mass shooting that killed a two-star Army general and wounded 18 other people in Afghanistan on Aug. 5 was carried out by a lone Afghan soldier who did not have any apparent ties to the Taliban and who simply seized “a target of opportunity,” according to a U.S. military investigation.

The investigation, released by U.S. Central Command on Thursday, found that Maj. Gen. Harold Greene, of Falls Church, Va., died immediately after being shot multiple times in the pelvis, head and neck by an army private named Rafiqullah, 22, who also was killed in the incident. The report found that Rafiqullah opened fire from a bathroom window in a military police barracks less than 15 meters away from the nearest person he targeted. He had previously expressed disdain for Americans.

Greene was the highest-ranking U.S. officer killed in a combat zone since the Vietnam War. The others wounded in the shooting included German Army Brig. Gen. Michael Bartscher and Afghan Brig. Gen. Miyan-Yar Gulalm Sahki. The names of the others wounded are redacted from the newly released documents, but they include 10 Americans, three Afghans and two individuals from Britain.

The attack occurred at the Marshal Fahim National Defense University. The facility, in the Qarga district of Kabul province and west of the city, was known as the Afghan National Defense University until this year. Greene, the deputy commanding general of Combined Security Command – Afghanistan, and the others were at the academy to review and discuss a construction project that was underway and highlight the school’s potential to train Afghan officers.

The report said that Rafiqullah was not believed to have been a member of the Taliban or any other extremist group. He may have been “self-radicalized” or had a mental illness, investigators found. He fired between 27 to 30 rounds from an M-16 that carried up to 30 in its magazine, and was killed by coalition service members.

It “appears the shooting was not premeditated, and the shooter simply took advantage of a target of opportunity provided by the close gathering,” according to the investigation report, completed by Army Brig. Gen. Donald E. Jackson Jr.

An Afghan interpreter for a contractor at the academy told investigators that Rafiqullah had expressed dislike for Americans before. The shooter had previously challenged the interpreter on why he worked for Americans, and the interpreter responded that in doing so, he also was helping the Afghan National Army. The answer seemed to satisfy Rafiqullah, the interpreter recalled.

The shooter also had grievances with his own Afghan military commanders. He had been denied time off recently, and was frustrated after working a double shift recently while other Afghan soldiers relaxed, Afghan troops said. Some Afghan soldiers expressed surprise about his involvement in the attack, saying he was well liked in their unit.

Photographs included in the report released Thursday underscore how close together the ambushed troops were when Rafiqullah began shooting. The photographs were likely available because the shooting occurred during a meeting of senior officers.

This image released by CENTCOM shows he attack site afterward. Investigators labeled the window used by Rafiqullah with a red dot:

This image, taken 10 minutes before the shooting, shows how close Americans and Afghans were standing at the training academy before the attack. Investigators labeled those who were later wounded with a red dot:

The window the shooter used opened outward, limiting the angles at which he could shoot. This photograph released by U.S. officials shows it riddled with bullet holes after American troops returned fire and hit Rafiqullah:

Coalition troops cleared the building that Rafiqullah used to make sure that there weren’t any other threats, and found him barely breathing while slumped in a bathroom shower stall. They checked him for explosives, and he died moments later, the investigation found.

Some witnesses said they heard shots from within the bathroom after Rafiqullah’s attack, raising the question whether Afghan soldiers inside the building shot at him. Investigators could not determine who fired the fatal shots.