Photographing in socialist Hungary in the decades leading to democratic rule, Andras Bankuti knew that everything was political. Aware of taboo subjects – religion, poverty, drugs, among others – he resorted to self-censorship. “The second I pressed the shutter release,” he said, “I knew which of my pictures could not be published.”

Hungary was ruled as a socialist republic from 1949 until 1989, when activists and intellectuals pressed the government to adopt a democratic political system with a revised constitution that affirmed civil rights. Mr. Bankuti’s images from the 1980s and 1990s straddle this complex period, and include intimate depictions of struggling families — people sleeping in the streets, piled together on a bed — as well as celebratory christenings and rousing political gatherings. And even as the state loosened its grip, he had to be careful about his audience.

“All the conscientious reporters worked for their own archives,” he said. “The negatives got stored away in drawers, maybe shown to small professional audiences in exhibition rooms tucked away in nameless alleyways.”

Photo

Mr. Bankuti was born into a bilingual family: His Russian-born mother took him to museums, and his Hungarian-born father was a radio reporter whom he accompanied to interviews. When a long hospitalization toward the end of high school forced him to miss preparations for university entrance exams, he decided to enroll in a vocational school for photography. He continued working in the photo departments of various publications, and for 16 years, he was both a photographer and the head of the photography department for HVG, an economics weekly. Along with Karoly Kincses and Magdolna Kolta, Mr. Bankuti founded the Hungarian Photographers House (Mai Manó House).

His work from that era had a wide range. He photographed the fringe Hungarian punk scene, earning invitations to house parties and concerts, and his right to take photographs by paying for drinks. He has been taking pictures of the Ballet of Gyor since the company was founded in 1979, covering generations of dancers onstage and backstage, through lyrical moments and physical hardships.

He portrayed precarious reality not only in Hungary, but also in neighboring countries, including the demolition of the Berlin Wall, the civil war in Yugoslavia and the fall of the Soviet Union. “I think I had an eye for the changes,” he said. “A good picture is a good picture everywhere, and with the right caption you can make the circumstances understandable even to those in different countries.”

Throughout, he was guided by the desire to get close to his subjects.

“I have to approach my subjects so that they feel my empathy, and reward me with their trust,” Mr. Bankuti said. “You can detect if either of these is lacking in a picture.”

Photo

Gaining that trust was difficult when he started working for the press 40 years ago, an era when socialism seemed undefeatable and politics permeated every aspect of life. “Even professional developments had shades of the political,” he said. “If certain changes seemed uncomfortable for the leadership, the initiator of the reform was soon proclaimed a traitor, an enemy of communism. This was especially true for the press.” During the ’80s, reporting on poverty, Romani, religion or employment difficulties was forbidden. “According to the media, no drugs, prostitution, or pollution existed in Hungary,” he noted. “In such circumstances, we all had self-censorship; people knew exactly what could be published or not, and what to try to slip through to photo competitions.”

He recalled “investigations on cooked-up charges against me,” as well as when the head of the newly founded Hungarian stock exchange insinuated that a photo of his, depicting Transylvanian refugees sleeping at a railway station in Budapest, was “degrading the country.” Even the Hungarian Press Photo Competition provided an alternative outlet only in theory. When images he made of Pope John Paul II — that his editor discouraged him from even taking — were selected for exhibition, censors took them off the walls. Other images at the same exhibition were removed: one showing Russian foreign minister Andrei Gromyko in a hunting cap, rather than a hat; another showing nude extras on a film set.

Restrictions loosened after 1988, although “the extent still depended on the individual editors’ courage, as criticism still posed an existential threat.” He recounted the risk of photographing an ailing Janos Kadar, the Hungarian communist leader and the General Secretary of the Hungarian Socialist Workers’ Party, who presided over the country from 1956 until 1988. “I took it at a public event, but still I had to look around to see if I was being watched by the state news agency’s employees. I could have easily been arrested. I took the picture because you could already sense, from his speeches, that he was on his way down,” Mr. Bankuti said. “I wanted to picture this state. Today it is an emblematic picture of the end of his regime.”

Correction: January 10, 2018

An earlier version of a picture caption with this article misidentified one of the subjects in the photograph. He is Sandor Gaspar, president of the Hungarian National Council of Trade Unions, not the Hungarian actor of the same name.

Follow @nytimesphoto on Twitter. You can also find Lens on Facebook and Instagram.