Impeach the president. End racism. Save the planet. Stop the war.

The extremists and protesters who spread their messages of love and hate across the Big Apple a half-century ago were secretly surveilled by the NYPD, a trove of newly unearthed photos reveals.

Cops had their eye on the deadly Black Liberation Army, and somehow got their hands on a useful shot of 13 beret-wearing members of the radical terror outfit posing together for a group portrait.

The Communist Party, the Black Panthers, the Nation of Islam and the neo-fascist, white-supremacist National Renaissance Party were spied on for criminal activity.

Some 60 photos were made available to The Post by the city’s Department of Records and Information Services, which acquired them from the NYPD.

Many of the groups’ protests parallel those of 2017 — and the similarities spurred Pauline Toole, the commissioner of the Department of Records and Information Services, to make them public.

“At this point in history, we thought it was a really interesting time to bring out some of the materials from the ’60s and ’70s and try to make connections between events that were happening then, and events happening today,” Toole told The Post on Thursday.

“There has been a lot more activism in the past several years in an organized way,” she said. “Because of the Black Lives Matter movement, because of the Women’s March, people organizing against the current president — his policies, at least — there’s a lot more interest.”

“This is what the New York City Police Department collected when they were doing their surveillance,” Toole said.

“Some of these photos were taken from above. Some were taken in the crowd. All were taken from public spaces. They didn’t think this was something someone was going to put into an exhibit some 50-some years later.

“At the time, it was like, ‘Look, here’s Muhammad Ali meeting with Louis Farrakhan and Nation of Islam, and this is something we should be worried about.’ ”

‘BLA surveillance’

On Sept. 18, 1973, cops snapped this photo in the Bronx of a suspected member of the Black Liberation Army — a militant group that terrorized the city and NYPD by assassinating officers on the street and tossing grenades into open patrol car windows. In 1971, five members fatally shot Officers Joseph Piagentini and Waverly Jones, who were partners, in Harlem. The next year, four joined in fatally shooting Officers Gregory Foster and Rocco Laurie, also partners, on the Lower East Side. The man smoking in this photo was one of six charged with attempted murder and weapons possession after police raided a Bronx apartment.

‘Sisters in jail’

This shot from 1971, with no specific date, shows a group demonstrating in solidarity with the Panther 21 — a group of 21 Black Panther members charged with conspiring to blow up city sites, including the New York Botanical Gardens, the Queens Board of Education office and police stations in the Bronx and Manhattan. Charges were soon dropped against all but 13, and the remainder were acquitted in May 1971 after an eight-month Manhattan trial. Among the defendants was Afeni Shakur, mother of the rapper Tupac Shakur.

‘Smog city’

On Jan. 21, 1967, anti-pollution protesters marched to raise their voices against the city’s worsening smog problem. For three days on the previous Thanksgiving weekend, New York’s skyscrapers had been enveloped in a record-setting, sulfurous cloud of pollution. Outraged residents took to the streets of Brooklyn — and took a shot at Con Ed, which was still burning coal, with a comic performance titled “King Con.” Public outcry helped spur reforms, including crackdowns on coal and emissions from trash incinerators and city buses.

‘Gay power’

This undated photo shows a gay power rally sometime after the June 1969 police raid on the Stonewall Inn in Greenwich Village. The raid prompted spontaneous, sometimes violent demonstrations in the city and beyond and led to the formation of the Gay Liberation Front and Gay Activist Alliance, demanding equal rights on behalf of the LGBT community.The city’s first gay pride parade took place June 28, 1970, along Christopher Street.

‘Neo-Nazis rally in Yorkville’

On March 18, 1966, James Madole — founder of the neo-fascist National Renaissance Party — addressed an audience of 200 people in the auditorium of Robert Wagner Junior High School in the Yorkville neighborhood on the Upper East Side. In the NYPD photo of the rally, the group’s SS-inspired lightning-bolt insignia is on sickening display as Madole spews his white-supremacist hate. Before the meeting ended, they chanted, “White man unite, white man fight.” Madole would die of cancer in 1979. His successor was killed by a mugger in 1980, and the group disbanded soon after.