The flag-draped coffin carrying the body of a two-star general killed by a ​terror-sympathizing ​Afghan soldier arrived at Dover Air Force Base in Delaware on Thursday morning amid questions about the breakdown that led to the insider attack.

Maj. Gen. Harold GreenePhoto: ZumaPress.com

Maj. Gen. Harold Greene, 55, is the highest-ranking US officer to be killed in combat since 1970 during the Vietnam War, and is the highest-ranking American officer killed in combat in the wars in Afghanistan and Iraq.

The 34-year US Army veteran was kill​​ed Tuesday in one of the bloodiest insider attacks of the long Afghanistan war when a gunman dressed as an Afghan soldier turned on allied troops at the national defense university, wounding about 15 US and coalition forces.

Greene, an Albany native, was a 1980 graduate of Rensselaer Polytechnic Institute in nearby Troy, where he earned degrees in engineering.

Greene was the deputy commanding general of the combined security transition command unit in Afghanistan. Trained as an engineer, he was involved in preparing Afghan forces for the departure of US-coalition troops at the end of this year.

A C-17 cargo plane brought Greene’s body to Dover, home to the nation’s largest military mortuary.

White-gloved soldiers solemnly carried a flag-draped metal case with Greene’s remains to a waiting mortuary vehicle as Army officials and other dignitaries saluted.

The incident underscored the tensions that persist as the US combat role winds down.

Meanwhile, Secretary of State John Kerry flew to Afghanistan late Thursday in an unannounced visit to press the country’s two feuding presidential candidates on the urgency of ending a bitter dispute over June elections and forming a new government by early September.

Kerry planned to meet both candidates — former Foreign Minister Abdullah Abdullah and former Finance Minister Ashraf Ghani Ahmadzai — on Thursday night and then meet with current Afghan President Hamid Karzai before he leaves Friday for an Asian security conference in Myanmar.