Stewart, who has been at M&S for four years, will replace Laurie McIlwee, who resigned in April after a tumultuous period in charge of Tesco's finances that included its first profit warning in more than 20 years.
Stewart, who also held the finance job at WH Smith, brings some much-needed retail experience to the Tesco board, which has been denuded by a string of senior departures.
In April, Tesco reported a second year of falling group profits. The chief executive, Philip Clarke, is under growing pressure to arrest falling UK market share as shoppers defect to cheaper rivals such as Aldi and Lidl.
Clarke has promised £200m of price cuts this year and is pushing through a store refurbishment programme.
Stewart's departure is a blow to M&S, which is also in the midst of a turnaround. He was lured to Tesco with a generous pay deal that will lift his basic salary from £579,000 at M&S to £750,000. He is being granted replacement share awards worth £1.7m in lieu of deferred share awards he will forfeit when he leaves M&S.
Tesco said two other performance-related awards were being taken into account but declined to give further details. Stewart's total remuneration package will be disclosed in the 2015 annual report.
The largesse of the deal comes despite the fact that M&S's recent poor results have meant that performance-related share awards have not paid out.
Tesco and M&S are yet to agree on the terms of Stewart's gardening leave but his start date could be six months away due to a non-compete clause in his M&S contract.
Clarke said: "We wanted a candidate who had the right blend of experience, leadership and values to play a leading role in the transformation of Tesco. We have found all three in Alan. I am looking forward to working alongside him and I know Tesco will benefit from the breadth and depth of his experience."
McIlwee quit Tesco after months of speculation about his future and amid reports of disagreements with Clarke over strategy. He had a tense relationship with the City, with some analysts critical of his financial forecasts. This year's annual report revealed that McIlwee, who has been given the title CFO emeritus, will collect a golden goodbye of almost £1m when he departs in October. He earned a salary of £886,420.
The Shore Capital analyst Clive Black said Stewart's move was a surprise. "For Tesco, I sense that it is a sound move. Alan is a solid man, albeit M&S has singularly failed to meet the guidance that he has presented to the market. Tesco represents another step for him.
"That said, the problems of M&S and Tesco revolve around more fundamental matters than the CFO."
Stewart, who started his career in investment banking with HSBC, became Thomas Cook's chief financial officer in 1998; three years later was appointed the UK chief executive. From there he moved to WH Smith as group finance director where he worked alongside Kate Swann to improve the company's performance. He left in 2008 to join aircraft leasing business AWAS.
Tesco said of Stewart's share awards: "The value of the shares which replace those he will forfeit was independently calculated based on current market forecasts for the future performance of M&S and the corresponding level of payout for each award. The most recent awards, due to pay out in three years, are subject to a clawback."
guardian.co.uk © Guardian News and Media Limited 2010