McWalter joined M&S in late-1999 and signed off its controversial ads using "real women", including the spot featuring a nude size-16 model.
The ads failed to produce a quick turnaround in M&S's fortunes but McWalter has consistently defended its agency, Rainey Kelly Campbell Roalfe/Y&R.
His departure is linked to a restructure of the M&S board, which has led to the scrapping of the board marketing director role. Its new chief executive, Roger Holmes, will head a board represented by an executive from each division of the company.
An M&S statement said McWalter is leaving "to pursue other interests outside the company". McWalter joined M&S from Woolworths, where he was the marketing director. He swiftly appointed RKCR/Y&R and Walker Media as M&S decided to move into advertising to improve its fortunes. Previously it had run product advertising for its financial services and food ranges but not for its core brand.
Following on from the "real women spots, which introduced the strapline "Exclusively for everyone", RKCR/ Y&R created a series of product-focused campaigns that have contributed to an improved sales performance by M&S.
It recently posted profits up 30 per cent to £629 million for the year to the end of March.
M&S's agency relationships will continue to be handled by Jude Bridges, the head of external marketing, who joined the retailer from Publicis last year.
Luc Vandevelde, the M&S chief executive who becomes its part-time chairman from January, said: "I want to thank Alan for the significant contribution he has made to the recovery, the restructuring and the lead he has taken in the redevelopment of the Marks & Spencer brand."
It recently unveiled improved annual results. It posted profits up 30 per cent to £629 million for the year to the end of March.
Turnover increased 3.8 per cent to £7.6 billion. M&S plans to return £2 billion to shareholders as part of a restructuring programme.