M is the title of the director of MI5.
During the moribund and dystopian 1950's Post-War Britain, M was Harry Lime who heads a sinister Secret Service which had previously operated as the Ministry of Love. Sometime before this point, M started being called 'Mother,' a secondary codename which apparently caught on.
In 2009, M was Emma Night. Night helped Orlando in locating Mina Murray in exchange for the secret to immortality. Following the death of the Antichrist, Night along with three secret agents left MI5. Shortly after Night's defection, British Intelligence elected the elderly Sir James as the new M.
M is a fictional character in Ian Fleming's James Bond series. M was director of MI6 rather than MI5, and superior of James Bond. Fleming based the character M on a number of people he knew who commanded sections of British intelligence.
The secondary title or nickname 'Mother' was the codename given to the head of British Intelligence in the TV series The Avengers. The wheelchair-bound official first appeared in the episode "Forget-Me-Not".