Tourists are flocking to New York City in record numbers — which is great for the local economy, but a bit of an embarrassment to the city officials who predicted that the mere fact that Donald Trump is president would keep foreigners away.

NYC & Co., the city tourism-marketing agency, warned early last year that travelers, especially international ones, would view America negatively thanks to Trump’s rhetoric and “isolationism.”

It even said the Big Apple would see a drop of 300,000 (later tweaked to 100,000) global tourists.

Oops: The tide kept right on coming in. The city scored 13.1 million international visitors in 2017, up 400,000 from the 2016 total. Add that to nearly 50 million domestic guests, and the city broke its tourism record for the eighth straight year.

Covering itself as well as it could, NYC & Co. said it was excited that the city overcame the “hurdles” of the new era, crediting its “New York City — Welcoming the World” campaign as having surmounted the supposed Trump effect.

Mayor Bill de Blasio played along, praising his minions for having countered the “headwinds from the White House.”

“We’re keeping our door to the world open,” said the mayor — after the numbers had already proved the point.