"It is a great privilege to be asked to coach Middlesex and to accept one of the plum jobs in world cricket," Law said on Monday.
"I have very much enjoyed my time with the West Indies and with the staff and players every success. There is never a good time to leave but the opportunity to work with Middlesex for four years at the home of cricket was too good to decline," he added.
"We believe Stuart is the right man to build on the foundations laid over the past decade," said Angus Fraser, Middlesex Cricket's Managing Director of Cricket.
"He will provide a fresh voice and a fresh vision to inspire our players, and drive them towards our twin goals of promotion back to Division One of the county championship and limited overs success.
Law, who played one test for Australia and 54 one-day internationals, had previously coached Sri Lanka and Bangladesh.