NEW YORK — When Zohran Mamdani took a commanding lead in the Democratic primary for mayor of New York City last week, his parents were just as surprised as the party’s establishment.

Both are accustomed to the spotlight — his mother as an Oscar-nominated filmmaker and his father as a Columbia University professor. Neither expected to be this close to the halls of power.

Mamdani, 33, has credited his parents with providing him a “privileged upbringing” that included constant discussion of politics and global affairs. But at a moment of intense political fights over conflict in the Middle East, his parents’ critical views of Israel and his father’s academic work on settler colonialism and human rights could make them a target of attacks from the right.

The concept of settler colonialism has become especially fraught during the war in the Gaza Strip, as some supporters of Palestinians have applied the term to Israel, which some critics say is unfair.

“We hadn’t bargained for being parents of a prospective mayor,” Mahmood Mamdani, 79, the candidate’s father and a renowned professor of international affairs and anthropology, said in the couple’s Manhattan apartment the morning after the primary.

Mira Nair, 67, Mamdani’s mother, directed “Salaam Bombay!,” “Mississippi Masala” and “Monsoon Wedding,” among other films.

Over the past year, in between making films, she has canvassed for her son and cooked biryani and chicken for him and his campaign staffers. Both parents emphasized that their son, a democratic socialist who could become the city’s first Muslim mayor, has not turned to them for political advice. But they may now find themselves drawn into the campaign nonetheless.

“There’s obviously a long history of people in politics being attacked for views expressed by family members,” said Brendan Nyhan, a government professor at Dartmouth College.

In American politics, candidates have often invoked their opponents’ relatives to try to taint the image of the person running for office. President Donald Trump, for example, promoted the so-called birther conspiracy theory against President Barack Obama, whose father was born in Kenya; tried to link Sen. Ted Cruz’s father to the assassination of President John F. Kennedy; and mocked President Joe Biden for his son Hunter’s legal troubles.

During Mamdani’s rapid political rise, the anonymous pro-Israel group Canary Mission, which has doxxed critics of Israel, has attacked his mother and his father. Nair declined an invitation to a film festival in Israel in 2013, saying on social media that she would not visit the country until “apartheid is over.”

The elder Mamdani, who has described Zionists as oppressors in some of his writings, led teach-ins at Columbia’s encampments protesting the war in Gaza last year and criticized the university’s response to the protests.

He has also been outspoken about what he sees as the dangers of conflating criticism of Israel with antisemitism. His son, too, has been critical of Israel and its treatment of Palestinians, which has drawn accusations of antisemitism that he vigorously rejects.

Some prominent Jewish leaders have urged New Yorkers to examine the broader political context shaping the critiques of Mamdani and his father.

“Legitimate concerns about antisemitism are being exploited — both in the mayoral race specifically, and more broadly in the conversation around universities and democracy, to pit communities against each other,” said Amy Spitalnick, CEO of the Jewish Council for Public Affairs who identifies as a liberal Zionist.

In an interview, Mamdani’s parents disagreed about how much their work had influenced his worldview.

“He’s his own person,” Mahmood Mamdani said. “Now, of course what we do as his parents is part of the environment in which he grew up, and he couldn’t help but engage with it. That doesn’t mean anything is reflected back on us.”

“I don’t agree!” Nair said. “Of course the world we live in, and what we write and film and think about, is the world that Zohran has very much absorbed.”

Nair, who is Indian, met Mahmood Mamdani in the late 1980s in Uganda. He was a professor at Makerere University in Kampala, the country’s capital, where Zohran was born. At the time, Nair was researching for the screenplay of the romantic comedy “Mississippi Masala,” following her acclaimed movie “Salaam Bombay!,” which was nominated for Best International Feature Film at the 1989 Academy Awards.

Their work took them around the world, shaping an unusual childhood for their son. The family lived for a time in South Africa, where Mahmood Mamdani was the director of the African Studies center at the University of Cape Town.

Mahmood Mamdani recalled that a teacher in Cape Town had once reported Zohran for a surprising answer to the question of what color he is. While the other children in the class said white, Black or colored (a term used in South Africa for people of mixed race), Zohran answered “mustard.”

“I found it most touching,” his father recalled.

Mahmood Mamdani is a major figure in the field of post-colonialism at Columbia, where he has taught since 1999. His scholarship has touched on the legacy of colonialism in Africa, the simplistic way many Westerners view Muslims and how international discussions about human rights spotlight some atrocities while sidelining others.

The term “colonialism” has become a political battlefield in recent years, particularly when it is applied to the relationship between Israel and the Palestinian people.

In his best-known book, “Good Muslim, Bad Muslim,” Mahmood Mamdani wrote: “Internationally, there is one state that stands in defiance of practically every U.N. resolution that affects it: Israel. In the international community, Israel stands for the exercise of power with impunity.”

Mahmood Mamdani recalled the moment that he understood how the city’s politics — and especially anti-Muslim sentiment after the Sept. 11, 2001, attacks — had affected his son. He remembered asking Zohran, then an adolescent, which of three quintessential New York City jobs he would prefer: hot dog salesman, sanitation worker or police officer.

“He said: ‘Well, I can’t be a policeman, not now in New York City.’ He was referring, of course, to 9/11,” Mahmood Mamdani recalled. “He said: ‘I don’t think I want to be selling hot dogs. It just makes people fat and unhappy.’ He said, ‘I think I’d rather be the garbage collector who cleans up places.’ ”