Gad Beck, whose dangerous life as a half-Jewish gay man in the capital of Nazi Germany during World War II represents one of the 20th century’s more unusual stories of human survival, died June 24 at a senior citizens home in Berlin. He was 88.

His death was first reported by the Jerusalem Post. No cause of death could be ascertained.

With the passage of time, it has become known that not even Nazi ruthlessness and efficiency could eliminate all Jews and gays from Hitler’s Germany. Some slipped through holes in the dragnet, or crevices in the edifice of death, which enabled Mr. Beck to become known as one of the last gay Jewish survivors of the Holocaust.

Mr. Beck was a leader among Jews who dodged the Nazis in Berlin, the heart of the Third Reich, and who took risks to help others trying to do the same.

He published a firsthand account of his experiences, “An Underground Life: Memoirs of a Gay Jew in Nazi Berlin,” written with Frank Heibert. The autobiography, published in 1999, embraced both the historic tragedy and the daily details of his precarious existence. Mr. Beck’s ability to remain alive at a time of constant danger involved forged papers, false identities and the good will of many people.

His narrative struck reviewers as a monument to determination, endurance and nerve. In one episode, he dressed as a Nazi to dupe the authorities into releasing a lover.

As a member of two groups persecuted by the Nazis, Mr. Beck appeared to view his religion as a greater peril than his sexual orientation.

“I was always a step away from the concentration camps,” he once said, “not because I was gay but because I was Jewish.”

In fact, he was the son of a Jewish father and a mother who had not been born Jewish, which apparently gave him at least temporary protection from the Nazi regime.

Mr. Beck said his parents were surprised and supportive when he first told them of his homosexuality.

“They said: ‘Oh my God, he’s Jewish and he’s gay,’ ” Mr. Beck once recalled. ” ‘Either way, he’ll be persecuted. This cannot end well.’ ”

While working with an outfit of underground Zionist operatives, Mr. Beck found a kindred spirit, Manfred Lewin, and the two became lovers.

“People were starving for love,” Mr. Beck said. “I gave Manfred love, and he took it. There was no talk about ‘gay this’ or ‘gay that,’ like you have today. It was about emotion and trust.”

Lewin was picked up in 1942 and sent with his family to a detention center. As Mr. Beck told it, he obtained an ill-fitting Nazi uniform and marched into the center to assert a concocted need for Lewin’s release. The commander emphasized that Lewin’s release had to be temporary, ordering Mr. Beck to “bring us back this Jew.”

This would be no problem, Mr. Beck responded, asking: “What would I want with a Jew?”

Mr. Beck and Lewin walked out. But then Lewin turned back, unwilling to abandon his family. He did not survive the war.

Mr. Beck was credited with smuggling rations, cash and clothes to fellow Jews who were living in hiding. He was also said to have helped some Jews flee to safety in Switzerland.

Only three months before the Nazi surrender, he was betrayed, arrested and held by the Gestapo. Finally, he recalled, a Red Army soldier came to the place where he was confined and told him: “Brother, you are free.”

Gerhard “Gad” Beck was born in Berlin on June 30, 1923. According to the Jerusalem Post, Mr. Beck is survived by his partner of 35 years, Julius Laufer, but a complete list of survivors could not be determined.

After the war, he took part in efforts to bring Jewish refugees to Palestine. He aided in Israel’s war for independence.

In the 1970s, he went back to Berlin and taught German students about the Jewish culture that had once flourished in their country.

“I mustered strength from the individual moments of happiness that I was always able to wring out of life,” Mr. Beck once said, “no matter how dire the straits.”