Greek μάντις mantis meant "prophet, seer" ("vocalism obscure" says the AHD). The OED says "Ancient etymologists attribute the name of the insect partly to its posture, and partly to the supposed divinatory significance of its appearance or movements."
1658 J. ROWLAND tr. T. Muffet Theater of Insects in Topsell's Hist. Four-footed Beasts (rev. ed.) xvi. 982, I have seen only three kinds [of the lesser Locusts]..they are called Mantes, foretellers... They do shew the Spring to be at hand, so Anacreon the Poet sang; or else they foretell dearth and famine, as Cælius the Scholiast of Theocritus have observed.
In Sanskrit it became मन् man "to think" and मन्त्र mantra meaning "counsel" among other things, and मन्त्रिन् mantrin "king's counsellor, minister". This was borrowed into Malay as menteri, then into Portuguese as mandarim, mandarin.