The former Light Blues goalkeeper knocked back Tigers boss Nigel Adkins’ offer of a new deal at the KCOM Stadium.
Instead, the 36-year-old has decided to return to Rangers six years after quitting in the wake of the club’s financial meltdown.
McGregor becomes Steven Gerrard’s second signing since taking over as Rangers boss, following the capture of midfielder Scott Arfield from Burnley earlier this week.
The 35-cap Scotland international won three league titles, a hat-trick of Scottish Cups and five League Cup titles during his first Rangers stint.
After he joined the exodus of big-name stars from the club in 2012, he spent a year with Besiktas in Turkey before joining Hull.
He has since racked up almost 150 appearances for the KCOM Stadium club but has now decided it is time to return north.
Bayer Leverkusen have signed keeper Lukas Hradecky from Eintracht Frankfurt ahead of Bernd Leno's likely exit.