In December 2012, the Senate voted on a package of sanctions that targeted dozens of Russian officials who had participated in gross human-rights violations in the country. The so-called Magnitsky Act received overwhelming bipartisan support, passing 92-4.

But among the nays was the Independent senator from Vermont, Bernie Sanders.

The Democratic presidential candidate never explained why he voted against the bill that was designed to highlight human-rights violations in Russia.

But the self-described socialist from Brooklyn has long had a soft spot for ultra-left-wing regimes, often glossing over their leaders’ penchant for totalitarianism, human-rights abuses, political repression and corruption.

Just last month, Sanders, 78, praised the late Cuban dictator Fidel Castro for making “progress” with education on the island.

“When Fidel Castro came to office, you know what he did?” asked Sanders in a “60 Minutes” interview days before the Democratic primary debate in Charleston, South Carolina. “He had a massive literacy program. Is that a bad thing? Even though Fidel Castro did it?”

Though Sanders has visited Cuba on a few occasions, he has long seemed blind to the fate of those who dared speak out against the ruling class. After Castro’s death in 2016, Human Rights Watch noted that “during his nearly five decades of rule in Cuba, Fidel Castro built a repressive system that punished virtually all forms of dissent, a dark legacy that lives on even after his death.”

In 1985, Sanders instead highlighted the despot’s supposed accomplishments: “They forget that he educated their kids, gave them health care, totally transformed the society.”

And, starting as far back as 1981, when he became mayor of a small Vermont city, Sanders has been sharply critical of American foreign policy, siding with Latin American demagogues, even as they were accused of everything from election fraud to even genocide.

Now with 501 delegates pledged to his presidential campaign, Sanders is in the fight of his life against front-runner Joe Biden for the Democratic nomination. If he wins, the senator known for his unwavering radical views may be in a position to formulate US foreign policy.

Bernie Sanders was born in Brooklyn in 1941 to a lower-middle-class Jewish family. The bespectacled intellectual said he was passionate about politics from a young age. He attended Brooklyn College and graduated from the University of Chicago with a political science degree in 1964. While in Chicago, he joined the Young People’s Socialist League and fought for civil rights. Four years later, he moved to Vermont and took on a series of odd jobs that included working as a writer, documentary filmmaker and carpenter, before running for mayor of Burlington, a college town with a population of just over 37,000. He won by just ten votes and used his elected position as a launchpad to forge relationships with left-wing leaders around the world.

At his desk at the mayor’s office, Sanders began to write letters, most of them addressed to President Ronald Reagan, urging him to “stop killing the innocent people of Nicaragua.”

In the summer of 1979, the left-wing Sandinista National Liberation Front had toppled Anastasio Somoza, the dictator whose family had ruled the country since 1936.

Elated with the Sandinista victory, leftists from around the world converged on the Central American country to be part of the “revolution” and volunteer with the new government. But at the height of the Cold War, US officials were so worried that Nicaragua would become another Cuba and fall under the Soviet sphere of influence that they financed the rebel Contras to kick them out.

‘The word genocide is nonsense. It is a complicated issue’

The mayor of Burlington worried about his country’s support of the rebels and longed to go to Nicaragua. In 1985, he got his wish. Thanks to his dogged support of their cause, Sanders was invited by the Sandinista government to commemorate the sixth anniversary of their revolution. In July 1985, the 43-year-old mayor became the highest-ranking American official at the event, where he met with Nicaraguan leader Daniel Ortega and was escorted around the country by Sandinista handlers along with a group of dignitaries from Eastern Communist Bloc countries.

“The trip to Nicaragua was a profoundly emotional experience,” he wrote in his 1997 memoir “Outsider in the White House.

At the anniversary celebration in Managua, Sanders was introduced before a crowd of hundreds of thousands of people. “I will never forget that in the front row of the huge crowd were dozens and dozens of amputees in wheelchairs — young soldiers, many of them in their teens, who had lost their legs in a war foisted on them and financed by the US government,” he wrote.

But while he had great sympathy for the soldiers, he refused to take a stand against the Sandinista government, which was launching a murderous campaign against the Miskito Indians. Many of this tribe lived near Puerto Cabezas, the Nicaraguan town Sanders visited on that trip in order to forge a “sister city” agreement with Burlington that continues to this day.

In their battle against the Contras, Sandinista soldiers targeted Miskito Indians and kicked them off their land. In 1984, the Organization of American States issued a scathing report against the Sandinista leadership, denouncing what they called the government’s “illegal killings” and torture of the Miskito Indians.

During his 1985 visit to the town, Sanders admitted to being shaken by the “wailing of family members who received their dead relatives back into the village” — a situation he called an “unforgettable experience” in his memoir.

But when he returned to the United States, he shrugged off the OAS report of the massacres.

“The word genocide is nonsense,” said Sanders when asked about the plight of the Miskitos in a combative press conference in July 1985. “It is a complicated issue. I’m not an expert.”

After eight years in the mayor’s office, Sanders was ready for a bigger role in political life, and in 1991 he became Vermont’s only congressman, serving for 16 years before running for the Senate in 2006, where he sits to this day. He continues to take controversial stands on demagogues and glosses over human-rights abuses in the rest of Latin America, often ignoring reports of widespread corruption in Brazil, Bolivia and Venezuela.

In Venezuela, leader Nicolas Maduro has been widely condemned for undermining democracy, violently suppressing human rights and imposing policies that have led to runaway inflation and the collapse of the economy since he came to power in 2013. There is widespread support for his ouster among Western leaders, led by the United States, which has recognized Juan Guaidó as the legitimate leader.

Although Sanders has lately described Maduro as “abusive,” he has stopped short of demanding that the dictator be removed from office. And he has refused to recognize Guaidó as Venezuela’s legitimate interim president.

“That is a decision of the Venezuelan people, so I think . . . there’s got to be a free and fair election,” said Sanders in a Univision interview last year. “What must not happen is that the United States must not use military force and intervene again as it has done in the past in Latin America.”

Sanders had long been a friend to Maduro’s predecessor, Hugo Chavez, signing a letter of support for his regime in 2003 at a time when the dictator was using troops and tear gas to crack down against opposition protests, according to a Wall Street Journal article in 2019.

And in 2011, his official Senate Web page re-printed an editorial from a New Hampshire newspaper that stated, “These days, the American dream is more apt to be realized in South America, in places such as Ecuador, Venezuela and Argentina.” (Lately, however, Sanders has tried to distance himself from Venezuela, calling Chavez “a dead communist dictator” in 2016.)

In Brazil, Sanders has unconditionally supported former Brazilian President Luiz Inacio “Lula” da Silva, even as he was jailed in 2018, convicted of money laundering and accepting more than $1.2 million in bribes in improvements to a beachfront home from a construction company doing business with the federal government. Sanders rallied to his defense, calling the charges against Lula, as he is known in Brazil,” a politicized persecution.”

In Bolivia, Sanders has backed former President Evo Morales, even as he was accused of engaging in widespread fraud to hang onto a fourth term last year.

“I am very concerned about what appears to be a coup in Bolivia, where the military, after weeks of political unrest, intervened to remove President Evo Morales,” Sanders tweeted last November. “The US must call for an end to violence and support Bolivia’s democratic institutions.”

But according to the OAS, it was Morales himself who had subverted those democratic institutions. The agency accused his regime of “clear manipulations” of the voting system in the October presidential election. And after voters took to the streets to riot against the government, Morales eventually fled to Mexico in November.

Although Sanders has recently blasted Russian leader Vladimir Putin as an “autocratic thug” and warned his administration in Moscow to stay out of the US elections, he also seems loyal to Russia, where he honeymooned in 1988.

When President Barack Obama sought to target Russia’s human-rights record with the Magnitsky Act, Sanders was silent.

“Nobody can really justify voting against a piece of legislation that condemns torturers and murderers,” said Bill Browder, a London-based financier who has spent the last several years lobbying governments around the world to get tough with Russia after the 2009 prison death of his tax attorney, Sergei Magnitsky, in whose memory the US legislation was named.

“I’m not being partisan here, but Bernie Sanders opposing this law makes no sense,” Browder told The Post.

According to the law, signed by President Obama in Dec 2012, Magnitsky “suffered systematic abuse . . . including repressive arrest and torture in custody.”

Although Sanders later supported the Global Magnitsky Act — a separate piece of legislation that condemned human-rights violations around the world — he has adamantly refused to point the finger at Russia. His Senate office refused comment last week.