Lt. Gen. Michael T. Flynn abruptly announced his retirement Wednesday as head of the Defense Intelligence Agency, after what current and former officials said were clashes with his boss and other opponents inside the Pentagon spy service.

Flynn’s deputy, David R. Shedd, is also retiring, according to a statement from the agency.