An Israeli soldier killed Wednesday by errant IDF gunfire during a Palestinian stabbing attack at the Etzion Junction was identified as Eliav Gelman, 30, an Air Force captain in the Israeli army’s reserve corps. He was on his way home from his base when attacked.

Thousands of people attended Gelman’s funeral at the Kfar Etzion cemetery Wednesday night, mourning the father of two whose wife is due to give birth in two months.

“Even as a military man the amount of time he would give his sons was extraordinary, and they were the envy of everyone around, Eliav and his boys,” neighbor Esti Uliel told the Walla news site.

According to an initial investigation of the incident, Gelman was attacked by a Palestinian man, 26-year-old Mamduh Amro, while standing at a bus stop at the junction at approximately 12:15 p.m.

Amro, a teacher from the village of Dura near Hebron, jumped on Gelman and may have succeeded in stabbing him before soldiers nearby opened fire.

“IDF forces at the scene responded and in order to thwart the attack fired toward the assailant. Initial investigation suggests that Captain Gelman was injured as a result of the fire,” an army statement said. Gelman was in uniform when the attack occurred, the army said.

One or more bullets accidentally struck Gelman, critically injuring him. He was taken to Shaare Zedek Medical Center in Jerusalem, the Magen David Adom rescue service said, where doctors pronounced him dead some two hours after the attack.

Israeli security forces and rescue personnel at the scene of a stabbing attack at Gush Etzion junction, on February 24, 2016. (Gershon Elinson/FLASH90)

Israeli security forces and rescue personnel at the scene of a stabbing attack at Gush Etzion junction, on February 24, 2016. (Gershon Elinson/FLASH90)

Gelman, a father of boys Yoav and Yair, ages 2 and 5, lived in the settlement of Karmei Tzur, in the south of the Etzion settlement bloc, south of Jerusalem.

He was originally from Kiryat Arba, a settlement on the outskirts of Hebron and had studied at the Mekor Haim Yeshiva, also in the Etzion bloc.

Gelman’s brother Eyal described him as deeply religious, studying the Bible and Talmud every day.

“He was the best of the group. Eliav was excellent, exact, loved and loving, he was connected to the people of Israel, the land of Israel, the Torah of Israel,” his brother Eyal told reporters in the Shaare Zedek Medical Center.

“He died in a battle we’ve been experiencing for a long time,” he said, holding back tears.

Despite the circumstances of the death, Gelman’s family said they were not angry at the army for the mistaken shooting, the Ynet news website reported.

IDF Major Benaya Sarel, 26, who was killed during an August 1 2014 firefight in Gaza Strip. (photo credit: IDF Spokesperson/FLASH90)

IDF Major Benaya Sarel, 26, who was killed during an August 1 2014 firefight in Gaza Strip. (photo credit: IDF Spokesperson/FLASH90)

Gelman’s brother-in-law was Benaya Sarel, an IDF soldier killed during the 2014 Gaza war who was also from Kiryat Arba.

The Etzion Regional Council posted a notice of Gelman’s death and offered condolences to his family.

With his death, Gelman becomes the 29th Israeli to be killed by Palestinian terror and violence since October, plus three non-Israelis. Nearly 170 Palestinians have been killed over the same period, some two-thirds of them while carrying out attacks and the rest during clashes with troops, according to the Israeli military.

Speaking shortly after the attack, President Reuven Rivlin told a meeting of a Arab municipal leaders that they must condemn terror.

“The fire of terrorism, which has taken from us so many victims, is the same fire which will burn the bridges that we are trying to build today. I send my deepest condolences to the bereaved family,” he said.

According to a preliminary army investigation, two soldiers opened fire toward Gelman’s attacker, hitting Gelman as well.

The attacker was moderately injured by the gunfire, and was also taken by MDA to a Jerusalem hospital.

The Etzion Junction has seen a spate of attacks, many targeting soldiers stationed at the intersection. In November, American teen Ezra Schwartz was killed in a terror attack at the site. It has been bolstered by a massive army presence in recent months.