The 27-year-old midfielder will officially join the Baggies on a Bosman transfer on July 1, after passing a Hawthorns medical and agreeing a three-year contract, plus a further year's option in the club's favour.
Albion's director of football administration Richard Garlick said: "Craig is someone we have followed for a long time and we are delighted to finally get him.
"We tried to bring him here in the January transfer window but it did not work out.
"We have continued to track him and he has expressed a real desire to be at this club following interest from elsewhere.
"He has the flexibility to play in a few positions across the midfield, scores goals, and can slot in at right-back if required.
"I think he will bring a freshness to our midfield area and his character will suit our dressing room.
"We know we have a big summer ahead of us and it is great to get our first signing done so early."
Gardner started his career with Aston Villa and played 80 times before moving across the city to join Birmingham City in January 2010.
The 27-year-old made a £6m switch to Sunderland in June 2011 where he played 100 times.