Diplomats have 529 legal places to park in New York City — but still racked up more than $16 million in parking tickets, The Post has learned.

The city has issued 219,902 parking violations to diplomatic vehicles including 18,008 alone to Egypt which owes $1.97 million, the most of any country.

Most of the $16 million in parking debt was accumulated before a 2002 agreement between the city and the US State Department that was supposed to curb abuses. But the accord hasn’t stopped scofflaw countries, including Senegal, Ivory Coast, Indonesia and Italy, from amassing tens of thousands in fines. Each nation owes some $24,000 for tickets received since 2002.

In total, the city issued 42,449 tickets since 2002, and $758,968 in fines remain outstanding.

The city can take away parking decals from any country that has more than three tickets outstanding for more than 100 days. But officials refused to disclose which nations are thumbing their noses at the rules, saying that doing so would be “unduly prejudicial.”

“We will continue to enforce the program in a way that works together with diplomatic community members to hold them to the same standards as any other New Yorkers,” said Penny Abeywardena, the commissioner for the Mayor’s Office of International Affairs.

The 2002 agreement gave each UN mission two designated spots and one or two spots to each consulate.

The city Department of Transportation, which puts up the parking signs, would not disclose their locations.

But a Freedom of Information Law request by The Post revealed 529 parking spots heavily concentrated on the east side of Manhattan, with an additional six spots located outside diplomatic residences. The city would not disclose the location of those spots.