Udal, 38, retired at the end of the 2007 English season after 18 years with his native Hampshire.
At the time he said the presence in the side of former Australia leg-spinner Shane Warne, Hampshire's captain, who has a season left on his contract with the southern county, was restricting his opportunities.
But now, instead of playing for minor county Berkshire, Udal will head to Lord's, Middlesex's home ground.
He said he'd been persauded to reverse his retirement from first-class cricket by Middlesex's director of cricket John Emburey, himself a former England off-spinner.
"I'm delighted to be given this unexpected opportunity to extend my playing career at Middlesex and am very excited at the thought of playing for another two years," Udal said in a statement issued by Middlesex Tuesday.
"Retirement, in hindsight, was the wrong choice for me and, due to John Emburey and Middlesex's persistence, I've been given a great chance to continue doing something I love and prove to people that I am still one of the best at what I do.
"I'd like to thank Middlesex for backing me and look forward to the next two years with great enthusiasm. The squad is very strong and I see no reason why we can't win something next season."
Udal played four Tests for England after winning surprise call-ups for 2005-06 tours Pakistan and India.
His Test career came after a decade of England exile following 10 one-day international appearances in 1994 and 1995.
"We are very fortunate to have gained the services of Shaun Udal," said Emburey. "Shaun's experience, knowledge and match-winning capabilities will complement a very determined Middlesex team in 2008."
Udal has taken 724 first-class wickets at an average of 32.66. His four Tests yielded eight wickets at 43 apiece.