Phillip Knightley, who was the only western journalist to interview British spy Kim Philby, a longtime double agent for the Soviet Union, and who wrote compelling books about journalism and the history of spycraft, died Wednesday in London. He was 87.

His death was first reported by the London Times. The cause was cancer.

Mr. Knightley had a colorful past that included sojourns in Fiji and India before he settled in London in the 1960s as an investigative reporter with the Sunday Times. In 1968, he was instrumental in describing the extent of Philby’s duplicity, which was at the center of Britain’s most infamous spy scandal of the 20th century.

In his book “The Master Spy,” Mr. Knightley called Philby “the most remarkable spy in the history of espionage.”

Philby, who was one of the highest-ranking officers in the British intelligence service, had secretly been a Soviet mole since the 1930s, along with several other communist-inspired upper-class students from Cambridge University.

Phillip Knightley in 2012. ( JUSTIN TALLIS/AFP/Getty Images)

After Philby was exposed as a spy by British intelligence officers in 1963, he settled in Moscow. Mr. Knightley wrote several letters to him each year, asking for permission to interview him. Philby finally consented in 1988.

Philby missed certain creature comforts of British life, including books, tobacco pipes and London Times crossword puzzles, but he remained committed to his communist ideals and was unrepentant about the harm he had done to his country.

“I have always operated at two levels, a personal level and a political one,’’ he explained to Mr. Knightley. “When the two have come in conflict, I have had to put politics first. This conflict can be very painful. I don’t like deceiving people, especially friends, and contrary to what others think, I feel very badly about it. But then decent soldiers feel badly about the necessity of killing in wartime.”

Philby died within months of Mr. Knightley’s interviews with him.

Mr. Knightley also had several other major stories throughout his career. He led an investigation in the early 1970s into the effects of thalidomide, a drug intended to ease the morning sickness of expectant mothers but that caused alarming deformities in thousands of babies in the 1950s and 1960s. Mr. Knightley’s investigative team uncovered hidden documents and demanded that the British health service and the drug’s distributor be held accountable for the damage.

Later, he showed that one of Britain’s richest families, the Vesteys, had structured their businesses to avoid paying income taxes.

As an author, Mr. Knightley published about a dozen books, including a history of Australia, a chronicle of 20th-century espionage, an autobiography and a study of the role of journalists during wartime, “The First Casualty.” (The title refers to a 1917 comment by U.S. Sen. Hiram Johnson (R-Calif.): “The first casualty when war comes is truth.”)

Mr. Knightley’s book, first published in 1975 and now considered a classic, casts a skeptical eye on war coverage since the Crimean War in the 19th century. Journalists and government propaganda machines, he argued, have both been guilty of mythmaking and deception.

“I wanted to challenge journalists to examine their own role in the promotion of war,” he wrote in the introduction to the 2004 edition of the book, “and urge them to consider the burden they bear — every time they write a story they have an unmeasurable but definite responsibility for what happens next.”

He praised journalists who broke free of their military minders while also cautioning against insensitivity and the excesses brought about by modern technology.

“The most intrusive medium in Vietnam was television, and, as the war went on, the hunger of editors for combat footage increased,” he wrote. He described one incident in which a cameraman hovered over a wounded Vietnamese soldier. The final thing the soldier saw before he died was “the zoom lens of a . . . sound camera capturing his last moments of life.”

Phillip George Knightley was born Jan. 23, 1929, in Sydney. His father was a sign painter.

Mr. Knightley began his newspaper career in 1946 and had a peripatetic youth. He sold coconut oil in Fiji, worked as a telephone linesman in New Zealand, sold vacuum cleaners door to door in Sydney and worked as a gardener in Melbourne.

But he always returned to journalism, and he first moved to London in 1954 as a correspondent for Australian newspapers. Later, he sold vending machines and set out on a round-the-world sailing voyage from London. He made it as far as Cornwall before turning back.

For a time, Mr. Knightley ran a successful Viennese-style restaurant in London that featured a yodeler. He became a wine connoisseur and, from his experience as a restaurateur, offered this advice to diners: Never order cooked oysters because they’re likely to be spoiled.

During the early 1960s, he lived in Mumbai, where he was the managing editor of a magazine — only to discover years later that it was a front for the CIA.

In 2010, Mr. Knightley put up bail money for his fellow Australian, WikiLeaks founder Julian Assange. His 25,000 pounds were forfeited when Assange sought sanctuary at the Ecuadoran Embassy in London.

In his 1997 autobiography, “A Hack’s Progress,” Mr. Knightley described his misadventures as a journalist, including a visit to the Punjab territory of India to interview Khan Abdul Ghaffar Khan, known as the “Muslim Gandhi.”

“I sat, notebook poised,” he wrote, “while he had a nap. Then he woke up, looked at me and said to his major-domo, ‘Who is this guy?,’ turned over and went back to sleep.”

Survivors include his wife of 52 years, the former Yvonne Fernandes of London; three children; and four grandchildren.

In addition to his interviews with Philby, Mr. Knightley spent so much time with spies that many people suspected he may have been one himself. He published a well-received book, “The Second Oldest Profession: Spies and Spying in the Twentieth Century,” in which he suggested that many spy agencies had been ineffectual at understanding the world’s problems.

Still, he was impressed by the skill and tactics of some of the people he met in the field. He described one meeting with a U.S. spy in “A Hack’s Progress,” saying he introduced himself as “George Knight.”

After an hour in which Mr. Knightley could elicit little information, the American politely escorted him to a taxi and told the driver, “Take Mr. Phillip George Knightley back to The Sunday Times.”

An earlier version of this story incorrectly credited Mr. Knightley with helping to reveal that Kim Philby was a Soviet spy. Journalists and the British intelligence service identified him as a spy in 1963, and Mr. Knightley subsequently described the extent of his activities. Mr. Knightley’s role in revealing the damaging effects of thalidomide was also overstated. His investigation called for British officials and the drug’s distributor to compensate people harmed by thalidomide.