People often ask "what is a legation?" So I provide the above photo of a page from a dictionary that was published when countries still had legations. And ministers, the people (well, at the time, the men) who headed them. Wikipedia has a limited or stub page on legations.
In Tangier, the American Legation and all the other legations ceased to be in 1956, the year of Morocco's independence. The buildings continued, usually reverting to the status of consulate or consulate general (the case of the US ConGen).
Over the years since Moroccan independence, the old legations and the consulates that replaced them gradually faded away. Just like the Dar Niaba, the office of the Naib or representative of the Moroccan foreign ministry, now a dilapidated administrative building for local government, whose occupants may be unaware of the fact that they are in a historically valuable building.
The American Legation, circa 1976. could have gone the same way. Fortunately, far-sighted people saw the significance of our building, and our current status as a US government-owned but privately run institute seems to be the kind of public-private hybrid that works.