As defined in the Oxford English Dictionary:

mandarim (1514; also mandarin) menteri (see MENTRI n.) or its etymon Sanskrit mantr (see MANTRI n.). Compare French mandarin counsellor (1581), Chinese literary language (1603), and in fig. (and ironic) use denoting an influential person from the early 19th cent.; Spanish mantelines, plural (1590 in the source translated in quot. 1589 at sense 1a), Mandarines, plural (1590 in the source translated in quot. 1604 at sense 1a). In form mandorijn after Dutch mandarijn, mandorijn (1596).

The change of t to d in Portuguese is perhaps due to influence from Portuguese mandar to order.

The Sanskrit word was the usual term for a counsellor or minister of state in pre-Islamic India. It was widely adopted in South-East Asia, and especially in the Malay-speaking states. The Portuguese were the first to apply it to Chinese officials, for whom the Chinese term was gun (see KUAN n.).

1. a. An official in any of the senior grades of the former imperial Chinese civil service. Also (more generally): a similar official in any East Asian country. Now hist. Mandarins were chosen by examination, and there were nine grades, each of which was distinguished by the material from which the round ornament or ‘button’ (see BUTTON n. 1g) on top of the official headgear was made.

b. An ornament (typically made of porcelain) representing a seated figure in traditional Chinese costume, with a head which continues to nod for a long time after being shaken. Now chiefly hist.    

c. A person (esp. an official) who commands considerable power or importance (freq. one perceived as reactionary and secretive); (spec. in the United Kingdom) a leading civil servant.

2. In form Mandarin.

a. The form of the Chinese language formerly used by officials and educated people generally; any of the varieties of this used as a standard language in China, spec. the Northern variety, which forms the basis of putonghua (see PUTONGHUA n.). Cf. earlier mandarin tongue n. at Compounds 1a and KUO-YÜ n. An important early European study of Mandarin was Francisco Varo's Arte de la Lengue Mandarina (1703), the earliest published grammar of any spoken form of Chinese.

b. colloq. Any obscurantist, esoteric, or exclusive variety of a language.