in run amok a verbal phrase first recorded 1670s, from Malay (Austronesian) amuk "attacking furiously." Earlier the word was used as a noun or adjective meaning "a frenzied Malay," originally in the Portuguese form amouco or amuco.
There are some of them [Javanese] who ... go out into the streets, and kill as many persons as they meet. ... These are called Amuco. ["The Book of Duarte Barbosa: An Account of the Countries Bordering on the Indian Ocean and Their Inhabitants," c. 1516, English translation]
Compare amuck.Related entries & more
It seems almost intuitive that the phrase run amok has something to do with muck.
In fact, it's often mistakenly written as run amuck.
The truth is far more interesting: it was transliterated in the late seventeenth century from the Malay word amuk, which was basically the equivalent of Norse beserk: it described a frenzied state of furious attack, often resulting in killing sprees.
This term was picked up by Portuguese sailors as amouco and was first used as an adjective or noun to describe the type of violent, unpredictable Malay they associated with the word. Through Proto-Malay, amuk is from a Proto-Malayo-Polynesian root sounding like hamuk; cognates exist in other Oceanic languages meaning "haunt" and "charge", so it has something to do with running into battle as well.