The South African batsman is a second significant marquee signing for head coach Stuart Law, following the announcement that Afghan spinner Mujeeb Ur Rahman will join his squad for the T20 campaign.
De Villiers, 35, is available to play in the first seven rounds and, if necessary, will return for the latter stages of the tournament.
The batsman has played in every Indian Premier League since its inception in 2008, scoring almost 4,000 runs at an average of just under 40.
“I have always wanted to play county cricket, and I am very much looking forward to joining Middlesex,” he said. “Playing at Lord’s is always a wonderful privilege.”
Law said: “It’s exciting for all here at Middlesex to announce the arrival of AB de Villiers for the T20 Blast this season.
“It’s a great opportunity for some of our younger players to pick the brain of one of the best players to have graced the game of cricket and for the support staff to work with him as well.”
Download our app and read this and other great stories on the move. Available for Android and iOS.