The West Indian, who recently hit a then-world record World Cup score of 215 against Zimbabwe, will join the club for five or six games in May and June, four of which will be at Taunton.
The 35-year-old Jamaican will make his debut either on 22 May or 29 May, depending on the progress of his IPL franchise, Royal Challengers Bangalore.
“Signing a world-class player of the quality of Chris Gayle is tremendously exciting for the club,” said new director of cricket, Matt Maynard.
“He will be a tremendous addition to our already extremely strong squad. He is an inspirational character and we are delighted to be bringing him to Somerset,” added the former England batsman.
“I’m excited about joining Somerset for the T20 Blast. Many of the club’s members and supporters will know that I came close to playing for the county in 2012. I’ve always felt that if I was able to, I wanted to honour that commitment to Somerset,” Gayle told the club’s official website.
The 6ft 3inch left-hander has scored 6,975 runs in his 195-match Twenty20 career, over 600 more than anyone else. He has also hit by far the most sixes in a T20 career; second-placed Kieron Pollard, a former Ciderman himself, has 151 fewer than Gayle’s total of 486 maximums.
He has also hit thirteen T20 centuries, eight more than anyone else has managed, including an unbeaten 175 for Royal Challengers Bangalore in the 2013 IPL, which remains the highest individual innings in a Twenty20 match.
Gayle’s debut will either come at Taunton against Sussex on 22 May or, in the event that he plays in the knockout stages of the IPL, 29 May at Chelmsford against Essex.
He will then be available for home matches against Kent (31 May), Hampshire (5 June) and Surrey (12 June) before finishing his brief stint with the county in their away game against Glamorgan on 13 June.
Gayle is the third signing by Somerset for the T20 Blast, with Pakistan all-rounder Sohail Tanvir joining the county for the first half of the competition before being replaced by New Zealand’s Corey Anderson.
Abdur Rehman, the Pakistani left-arm spinner, is not expected to play in the competition, despite being available, although he could feature after Gayle and Tanvir depart to play in the Caribbean Premier League.
Gayle is the only man to have hit a Test triple-century, ODI double-hundred and T20I hundred, and said: “I’m looking forward to coming to Taunton and scoring some runs.”