Original: It first appeared in a late twelfth century Provençal poem as a corruption of "Muhammad", but later it appeared as a term for a pagan idol in trial transcripts of the Inquisition of the Knights Templar in the early 1300s.
Simplified: It first appeared in trial transcripts during the inquisition of the Knights Templar in the early 1300s.