The 49-year-old ex-Yorkshire and England all-rounder has replaced Ottis Gibson on a five-year contract and will officially start his new role on November 1.
Former West Indies head coach and England bowling coach Gibson departed Yorkshire last week after three seasons in charge, having guided them to promotion to Division One of the County Championship.
McGrath said: “It is a great honour to be appointed head coach of Yorkshire Cricket’s men’s team and I am hugely excited by the challenge ahead.
“I know the history of this great club and the passion of the members and supporters, and I am absolutely determined to develop a team capable of delivering the success they deserve.
“It will be difficult to leave Essex after these incredible years and I would like to thank everyone involved with the club for the opportunity to be part of Essex Cricket’s history. The club is well positioned to keep moving forward in the years to come.”
Bradford-born McGrath spent 17 years as a player with Yorkshire – he was captain in 2003 – and made four Test and 14 one-day international appearances for England.
He retired as a player in 2012 and was a coaching consultant with the White Rose county before joining Essex, initially as assistant head coach, in 2016.
McGrath guided Essex to the County Championship and T20 Blast double in 2019 and the Bob Willis Cup in 2020.
Yorkshire’s interim chief executive officer Sanjay Patel said: “During the past nine years with Essex, Anthony has proved himself to be one of the most exciting and successful coaches in English cricket.
“He is renowned for his team’s attractive, attacking cricket, supporting and developing world class talent, and commitment to youth.
“In the club’s conversations leading up to this appointment, we were deeply impressed with his long-term vision for returning Yorkshire Cricket to the level we want to be competing at, and his drive and determination to achieve that.”