James K. Kallstrom, an FBI agent who became a familiar presence on the nightly news as chief of the criminal investigation into the crash of TWA Flight 800 off the coast of Long Island in 1996, a confounding disaster first suspected to be an act of terrorism but ultimately attributed to a fuel tank explosion, died July 3 at his home in Fairfield, Conn. He was 78.

He had a rare cancer of the blood, said his wife, Susan Kallstrom.

Mr. Kallstrom served with the Marine Corps in Vietnam before joining the FBI, where he rose over 28 years to the rank of assistant director in charge of the New York field office. An expert in electronic surveillance, he was described by the New York Times in 1996 as “a technical wizard who has bugged, wiretapped and generally bedeviled mobsters, terrorists and other criminals for more than two decades.”

Among other exploits, Mr. Kallstrom was credited with planting a bug in a couch used by John Gotti, the Mafia boss known as the “Teflon Don” before he was convicted on racketeering and murder charges and sentenced to life in prison in 1992.

“He took the bureau sort of light-years ahead of where we were at the time, and has put us in a wonderful position today,” then-FBI Director Louis J. Freeh told the Times when Mr. Kallstrom retired in 1997, referring to Mr. Kallstrom’s efforts to modernize the bureau’s technological capabilities.

No case in Mr. Kallstrom’s career came with greater attention or scrutiny than the inquiry into the downing of Trans World Airlines Flight 800, a Boeing 747 that took off from New York City on July 17, 1996, bound for Paris. Approximately 12 minutes into the flight, the plane exploded in midair, killing all 230 people aboard. Among those who perished was a close friend of Mr. Kallstrom’s, a flight attendant married to a fellow FBI agent.

Within nine minutes of the crash, Mr. Kallstrom felt his pager go off. For the next 16 months, his life was consumed by the investigation into what caused the crash. One of the most expansive inquiries in airline history, it involved numerous other agencies, including the National Transportation Safety Board and what is now the Bureau of Alcohol, Tobacco, Firearms and Explosives.

There seemed at the outset four possible explanations for the crash: a bomb, a missile, sabotage or mechanical malfunction. Mr. Kallstrom said that he initially felt certain the explosion was the result of criminal activity, a conviction that some critics later said hampered consideration of other possible causes.

But the 1993 bombing of the World Trade Center, which Mr. Kallstrom had helped investigate, remained fresh in public memory. Ramzi Ahmed Yousef, a terrorist ultimately convicted in that attack, also stood accused of planning attacks on U.S. airliners in the Pacific.

“You put them all together, after having Ramzi Yousef trying to blow up 12 airlines, the World Trade Center,” Mr. Kallstrom later said. “Did I think it was a good chance it was criminal? You better believe I did.”

The FBI investigation into the TWA Flight 800 crash involved more than 1,000 agents and interviews with 7,000 people. Divers painstakingly pulled wreckage from the water. Mr. Kallstrom’s day began at or before his 6 a.m. briefings and lasted long into the night. Colleagues told the Times he would sometimes excuse himself to go to the restroom, where he would splash cold water on himself for a jump-start.

But as the investigation proceeded and agents combed through thousands of remnants of the plane, no indication emerged of a bomb or friendly fire missile — a theory for which Mr. Kallstrom said there was not “one scintilla” of evidence. In November 1997, the FBI formally closed its investigation. The decision, Mr. Kallstrom said, was “based solely on the overwhelming absence of evidence indicating a crime, and the lack of any leads that could bear on the issue.”

“In fact,” he remarked, “we ran out of things to do.”

Other inquiries continued, however, and in 2000 the NTSB concluded that overheated fuel and air caused an explosion in the plane’s center fuel tank. The board could not determine with certainty the genesis of the explosion but cited a short circuit as a probable cause.

Critics of the FBI investigation contended that the bureau had not cooperated effectively with other agencies and had held on for too long to the possibility that the crash was the result of terrorist or criminal activity, even possibly seeking to suppress theories to the contrary. But Mr. Kallstrom defended his agents and the dogged attention they had given to the case.

“Imagine the notion of us looking for the obvious things in an investigation and not finding them and sort of vacating the scene,” he said in 1997. “We’re the Federal Bureau of Total Investigation,” he added, “not the Federal Bureau of the Obvious.”

Mr. Kallstrom retired from the FBI to begin a private-sector career in banking. After the 9/11 terrorist attacks, New York Gov. George E. Pataki effectively recalled him to service, appointing him head of a state public security office tasked with preventing future terrorist attacks.

James Keith Kallstrom was born in Worcester, Mass., on May 6, 1943. His father was a trumpeter in the big-band era and later a car salesman, and his mother was a nurse.

Mr. Kallstrom received a bachelor’s degree in business administration from the University of Massachusetts at Amherst in 1966, then joined the Marine Corps, attaining the rank of captain. He was deeply affected, he said, by the hostile reception he received in the United States upon his return from Vietnam.

“You’re trash, you’re scum, it tests your emotions,” he told the Times years later. “It makes you a different person. A more serious person.”

Mr. Kallstrom later became chairman of the Marine Corps-Law Enforcement Foundation, which provides educational scholarships for children whose parents died while serving in the Marine Corps, among other services.

Mr. Kallstrom joined the FBI after his discharge and spent most of his career in the New York office, where he was head of the special operations division. He became chief of the office in 1995 and held that post until his retirement.

Survivors include his wife of 50 years, the former Susan Auer, of Fairfield; two daughters, Erika Kallstrom Clancy of Brooklyn and Kristél Kallstrom Cosio of Ridgefield, Conn.; a brother; a sister; and three grandchildren.

In recent years, Mr. Kallstrom appeared frequently on media outlets including Fox News, where he voiced criticism of the FBI under the leadership of James B. Comey, the director who was fired by President Donald Trump in 2017 amid an investigation into possible collusion between Trump’s campaign and the Russian government during the 2016 election.

Mr. Kallstrom characterized Trump as a “patriot” and denounced Hillary Clinton, his 2016 Democratic opponent, and her husband, former president Bill Clinton, as a “crime family, basically.”

Referring to the investigation led by special counsel Robert S. Mueller III, a widely respected former FBI director, into allegations of Russian interference in the 2016 election, Mr. Kallstrom asserted on Fox News in 2018 that “it’s crystal clear that there’s a cabal, a far-reaching cabal, way beyond the bureau, into the intelligence community . . . into the National Security Council . . . into all these peripheral people, putting this thing together, this fraud against Trump.”

“I do not recognize the agency I gave 28 years of my life to,” he told the Wall Street Journal in 2018.

He said that of all the cases he had handled in those 28 years, the one that most stayed with him was the downing of TWA Flight 800.