M is the title and code letter for James Bond’s boss, the fictional head of the British Secret Intelligence Service, or MI6 (or MI7).
In Ian Fleming’s novels, M’s real name is Rear Admiral Sir Miles Messervy KCMG; the name, hinted at throughout the series, was finally revealed in The Man with the Golden Gun, Fleming’s final novel. In the films, only his first name Miles was revealed (in The Spy Who Loved Me), and he also has the rank of Rear Admiral.
The character of M is apocryphally based on Rear Admiral John H Godfrey, Director of the British Department of Naval Intelligence during World War II. During this time, Fleming was his assistant. Godfrey and Fleming were close friends and on first name terms, unlike M and Bond in the novels. Other names that have from time to time been referenced as a possible resemblance include Maxwell Knight, former head of counter-subversion in MI5, and Maurice Buckmaster, head of Section F of the SOE.
Fleming biographer John Pearson states in his 1966 book The Life of Ian Fleming that M may in fact be based on Fleming’s own mother:
“There is reason for thinking that a more telling lead to the real identity of M lies in the fact that as a boy Fleming often called his mother M. […] While Fleming was young, his mother was certainly one of the few people he was frightened of, and her sterness toward him, her unexplained demands, and her remorseless insistence on success find a curious and constant echo in the way M handles that hard-ridden, hard-killing agent, 007.”