The 62-year-old has been out of work since leaving his Wales role following the 1-0 UEFA EURO 2012 qualifying defeat in Montenegro last September.
"I am so honoured that the FFM chose me as coach of the Macedonia national team," Toshack told Macedonia's website. "I hope that together we can achieve success at international level."
Football Federation of Macedonia president Harry Hadzi-Risteski, who led negotiations with Toshack, said: "I must say that the talks were extremely constructive and above all there was a wonderful atmosphere.
"Mr Toshack expressed a great desire to lead our national team for us, not only as a federation but as a humble nation. John Toshack accepted the conditions offered and agreed to lead our squad in the qualifying campaign for the 2014 World Cup in Brazil."
Macedonia, who sacked coach Mirsad Jonuz in June, were last weekend drawn in qualifying Group A alongside both Wales and Scotland. Toshack will arrive in Macedonia on 25 August and will be officially presented a day later.
The experienced coach, whose club CV includes three spells in charge of Real Sociedad and two with Real Madrid as well as stints with Swansea, Sporting Lisbon and Besiktas among others, has had two previous cracks at international management.
After a brief period at the Wales helm in 1994, he returned for a second stint in 2004 and remained in the role for six years - overseeing 21 victories in 53 full-cap internationals and bringing through a new generation of players headed by Tottenham Hotspur's Gareth Bale.