The U.S. Navy SEAL who was killed by Islamic State militants in Iraq on Tuesday “felt called” to return to the war-torn country after the extremists group’s atrocities, according to his grandfather Bill Holmes.

Charles Keating IV, the grandson of Charles Keating Jr., who served time in prison as a result of the 1980s savings-and-loan scandals, had been an instructor at a base in California before he left for Iraq earlier this year, Mr. Holmes said in an interview.

The 31-year-old had joined the SEALs “because it was the hardest thing to do” and was planning to marry in November upon his return, Mr. Holmes said.

Mr. Keating was the third American service member to have been killed in Iraq since U.S. troops withdrew from the country in 2011. In Arizona, where Mr. Keating grew up, all state flags were lowered to half-staff on Wednesday.

U.S. Secretary of Defense Ash Carter said Mr. Keating, a first-class petty officer, died while rescuing Americans who were on a routine train-and-advise mission for Peshmerga forces that was surprised by Islamic State militants. Mr. Carter said the Navy SEAL was killed during the ensuing firefight, outside Mosul, Islamic State’s de facto capital in the country.