In 1941, Forrest Mars Sr., of the Mars candy company, struck a deal with Bruce Murrie, son of famed Hershey president William Murrie, to develop a hard-shelled candy with chocolate at the center. Mars needed Hershey’s chocolate because he anticipated there would be a chocolate shortage in the pending war, which turned out to be correct.
As such, the deal gave Murrie a 20% stake in the newly developed M&M; this stake was later bought out by Mars when chocolate rationing ended at the end of the war, in 1948. The name thus stood for “Mars & Murrie” the co-creators of the candy.
The “M&M” was modeled after a candy Forrest Mars, Sr. encountered while in Spain during the 1930s. During the Spanish civil war there, he observed soldiers eating chocolate pellets with a hard shell of tempered chocolate. This prevented the candies from melting, which was essential when included in the soldier's rations as they were.