The 27-year-old had been linked with the likes of Manchester United, Bayern Munich and Monaco but will instead leave Benfica for Zenit, agreeing a five-year contract with last season's Russian Premier League runners-up.
"Zenit and Benfica have agreed the move of the Argentina defender to the white and blue," said a statement on Zenit's website.
"His contract is for five years from July 1. The player will join the club after the World Cup."
No transfer fee was announced for the former Real Madrid player, who joined Benfica in 2012 after struggling to make the grade in Spain and returning to his homeland on loan.
Garay, who is currently at the World Cup finals with Argentina, revealed his delight via the Benfica website.
"I want to thank everyone who supported me in these three magnificent years I spent at Benfica. I want to especially thank the president, who believed and bet on me, and thank the manager, who made me improve and reach a level that makes me very proud," he said.
"This is the moment, I couldn't wait for any longer, but I'll take with me in my heart all the unforgettable moments I lived in Portugal. Thanks."