Although there were earlier references, the phrase “run amok” was partially popularized by Captain James Cook in 1772. From Cook’s book:
To run amock is to get drunk with opium… to sally forth from the house, kill the person or persons supposed to have injured the Amock, and any other person that attempts to impede his passage… indiscriminately killing and maiming villagers and animals in a frenzied attack.
In the Malay culture at the time, some believed the state of amok was caused by an evil spirit, “hantu belia”, entering the body of a person, who would then run amok, attacking and attempting to kill anyone they came across, only to recover later and return to normal, if they weren’t killed first. Because it was thought an evil spirit caused this, rather than the person doing it of their own free will, punishments for someone who ran amok and survived were typically light or even non-existent, with the person sometimes getting off scot-free.
Read more at the excellent Today I Found Out.