A mandarin () was a bureaucrat scholar in the history of China, Korea and Vietnam.
The term is generally applied to the officials appointed through the imperial examination system; it sometimes includes the eunuchs also involved in the governance of the above realms.
The English term comes from the Portuguese mandarim (spelled in Old Portuguese as mandarin, ˌmɐ̃dɐˈɾĩ). The Portuguese word was used in one of the earliest Portuguese reports about China: letters from the imprisoned survivors of the Tomé Pires' embassy, which were most likely written in 1524, and in Castanheda's História do descobrimento e conquista da Índia pelos portugueses (c. 1559). Matteo Ricci, who entered mainland China from Portuguese Macau in 1583, also said the Portuguese used the word.
The Portuguese word was thought by many to be related to mandador ("one who commands") and mandar ("to command"), from Latin mandare. Modern dictionaries, however, agree that it was in fact borrowed by Portuguese from the Malay menteri (in Jawi: منتري, ˈməntəri) which ultimately came from the Sanskrit mantri (Devanagari: मंत्री, meaning counselor or minister – etymologically linked to mantra). According to Malaysian scholar Ungku Abdul Aziz, the term had its origin when the Portuguese living in Malacca during the Malacca Sultanate wanted to meet with the higher officials in China and used the term "menteri", but with an added "n" because of their poor grasp of the language, to refer to higher officials.
In the 16th century, before the term mandarin became widespread in the European languages, the word Loutea (with various spelling variations) was often used in Europeans' travel reports to refer to Chinese scholar-officials. It is frequently used, for example, in Galeote Pereira's account of his experiences in China in 1548–1553, which was published in Europe in 1565, or (as Louthia) in Gaspar da Cruz' Treatise of China (1569). C. R. Boxer says the word comes from the Chinese 老爷 (Mandarin Pinyin: lǎoye; Amoy dialect: ló-tia; Quanzhou dialect: lāu-tia), which was commonly used by people in China to address officials.