This is one of Google’s most frequently asked questions about Hungary. Curiously, the question itself contains an error. In fact, the name of the Central-Eastern European country is Magyarország – the adjective magyar meaning "Hungarian" and the noun ország meaning "land" or "country".
Thus Hungary is not called magyar, but Magyarország in Hungarian.
However, the question remains: why is the indigenous name of the country so different to its English (or German, French, Spanish, etc.) equivalent? The answer is simple: they have two distinct roots. Just as in the case of Germany vs. Deutschland vs. Allemagne.
Exonym and endonym
It is, in fact, quite common that a tribe, people or nation refer to themselves with a different name to what others call them. To use the technical terms, the name a community uses for itself is an endonym; whereas an exonym is the name they are called by others, outside of the community. Deutschland or Magyarország are endonyms and Germany or Hungary are exonyms.
The endonym and the exonym are not necessarily different words (take France, for example, whose name is the same in French as in English) – but quite often they are. The case of Hungary is therefore far from unique.
How do nations get their names?
To understand why the English name for Hungary is so different to the endonym, we first need to understand how nations get their names.
According to one source, almost all countries are named after one of four things:
● a directional description of the country (for example the name of Austria comes from Latin Marchia austriaca, meaning “Eastern borderland”)
● a feature of the land (for example, the name of Costa Rica means “the rich coast”)
● an important person, most likely a man (for example, the United States of America is named after the explorer Amerigo Vespucci)
● name of a tribe, kingdom or ethnic group
The name Hungary comes from a Turkic tribe’s name
Hungary falls into this last category, just like one third of all countries. The Medieval Latin name Hungaria originates from the name of the Onogurs, a Turkic nomadic alliance of tribes. The Turkic name Onogur originally meant "ten arrows" or "ten Ogurs". Hungarians may have been members of this alliance. It is also possible that Hungarians were named after the Onogurs by accident. They appeared in the Carpathian Basin just after the Onogurs, which could have confused the people already settled there, who started using the same name for these newly arrived nomadic, Asian tribes.
The first written references are to be found in German texts, in the form of Ungarn. This word was, in turn, borrowed by neighbouring Slavic people who further transformed it to Uhry, Uhorsko, Węgry, etc. The “h” sound at the beginning of the word is a later development, through another coincidence. After the French stopped pronouncing the initial “h” sound, a confusion arose as to which words originally contained this sound. It is at this time that the French started using the form Hongrie, adding an extra “H” to the beginning of the word, perhaps also by association to the Huns, who were believed at the time to be the ancestors of the Hungarians. In Latin and English, the word was then further transformed to Hungaria and Hungary.
The name Magyar comes from a different tribe’s name
According to medieval texts and Hungarian tradition, Megyer was the name of one of the seven tribes that made up the Hungarians arriving in the Carpathian basin in the 9th century. At one point, Megyer became the dominant tribe, ruling over the other six. This is when the whole alliance of tribes came to refer to itself as Magyeri – or Magyar, as we say today.
Incidentally, this endonym is also used by various other nations, such as the neighbouring Slovakians, the Turkish, and various Middle-Eastern countries.
(Source: qz.com, nyest.hu, wikipedia.org)