The city Conflicts of Interest Board gave Mayor de Blasio the green light for a free trip to Germany because it achieved a “city purpose” — of opposing President Trump, a spokesman said Monday.

An email from the conflicts board’s lawyer, sent at 10 p.m. Friday — more than a day after de Blasio flew to Germany — said the board approved his itinerary based on a rule that allows acceptance of travel-related gifts if “the trip is for a city purpose and therefore could properly be paid for with city funds.”

Asked what city purpose was achieved by de Blasio giving the keynote speech at a G20 protest rally in Hamburg, spokesman Eric Phillips cited Hizzoner’s self-appointed role as a progressive foil to the president.

“He was representing New York City and our values, and providing an alternate American viewpoint to the deeply problematic vision of President Trump,” Phillips said.

“That leadership and voice will help strengthen New York City during important battles on the housing, public safety and health care cuts proposed by the Trump Administration.”

The organizers of the “Hamburg Shows Attitude” demonstration have said they paid for de Blasio and three aides, including Phillips, to attend “because it’s worth [it] to not just hear the voice of President Trump in Germany these days.”

De Blasio’s presumptive challenger, Assemblywoman Nicole Malliotakis (R-S.I.), scoffed at the notion the trip served a city purpose, saying: “It’s a political purpose! It’s a political trip!”

“The mayor needs to stop harping on Trump and take care of the traffic, transit and trash and the deteriorating quality of life,” she said.

Earlier in the day, Malliotakis demanded that de Blasio reveal how much taxpayers shelled out for the NYPD bodyguards who protected him during his trip, which she said “was clearly to enhance his national profile.”

City Hall referred questions about the cost to the NYPD, which wouldn’t say. “We do not discuss the specific security [arrangements] for dignitaries, including the mayor, the NYPD protects,” a police spokesman emailed.

“We do not discuss the specific security [arrangements] for dignitaries, including the mayor, the NYPD protects,” a department spokesman wrote in an email.

That stance clashed with the one that de Blasio and Police Commissioner James O’Neill took regarding the city’s protection of the president and his family at Trump Tower.

In a Feb. letter to members of Congress that was released by City Hall, O’Neill said the NYPD and FDNY spent $25.7 million on “presidential-level security” between the election and inauguration of President Trump.

O’Neill also pegged future costs for the NYPD at $308,000 a day when Trump is in town.

Law-enforcement sources told The Post that eight cops went to Germany last week, with four leaving on Tuesday to scout out locations and make arrangements for the mayor’s arrival and travel.

The mayor’s bodyguards work 18-hour days, in shifts of two days on and four days off, and in addition to regular pay and overtime, they each got a daily meal allowance of estimated at around $150 each, sources said.

Additional reporting by Larry Celona