Partners at both law firms have approved the deal although it is not yet clear how it will affect job numbers in Scotland where D&W employs the majority of its 450 staff.
Like others in the sector, D&W has been battling with reduced fee income, fierce competition for clients and the generally difficult economic conditions.
A spokeswoman for CMS confirmed the intention over time will be to transition to just using the CMS name.
In a statement, Caryn Penley and Allan Wernham, co-managing partners of Dundas & Wilson, said: "We believe that together Dundas & Wilson and CMS [will] have unrivalled strength and depth in Scotland, an exceptional UK platform and global reach."
CMS already has offices in Edinburgh and Aberdeen. D&W operates across Edinburgh, Glasgow and Aberdeen as well as London.
The spokeswoman said CMS staff will move into the larger D&W office in Edinburgh while D&W staff will move into CMS premises in both London and Aberdeen.
The merger agreement is expected to be formally completed on May 1 next year.
It will mean CMS will have more than 830 partners operating out of 57 offices across 31 countries.
D&W, which can trace its roots to 1759, abandoned plans to merge with London-based Bircham Dyson Bell almost two years ago after initial talks had taken place.
In its most recent financial results D&W reported a 10.6% fall in turnover from £54.5 million to £48.7m. There was a 21% drop in its pre-tax profit from £16.2m to £12.8m in the 12 months to April 30 this year.
Duncan Weston, managing partner at CMS in London, said: "Dundas & Wilson is the most prestigious law firm in Scotland and we are delighted they are joining CMS.
"With Dundas & Wilson, we believe we can offer many of our clients, particularly in the energy and financial institution sectors, a stronger and better service."
McGrigors has been the highest-profile name to disappear from the Scottish legal sector in recent times following its merger with Pinsent Masons in May last year.
Many other small firms have also been swallowed up by larger English rivals.
Lawyer Austin Lafferty, speaking in a personal capacity, said last night: "Having one of our biggest and most prestigious firms moving its centre of gravity from Edinburgh to London would not be my first choice. Dundas & Wilson must do what's best for its business and its partners in a legal world that is increasingly international, even global. But in Scotland, either as part of the UK or independent, it is essential we have the strongest legal profession and system we can.
"This is important for access to justice in our courts, for our contribution to the commercial wealth of Scotland, and for livelihoods for our solicitors, the many thousands of support staff, other professionals and businesses who rely on our solicitors.
"We need to grow our profession so that in time it is we Scots who hold the high ground. It is an interesting fact that after Glasgow and Edinburgh the biggest group of Scottish-qualified lawyers is in London."