The 28-year-old central defender spent four years with St Mirren in the top flight, having moved from Cowdenbeath in 2010, and becomes Ally McCoist's second acquisition of the summer following the arrival of Kenny Miller last week.
McGregor said: "I am absolutely delighted to get the chance to join Rangers. This is one of the biggest clubs in world football and I can't wait to play at Ibrox in front of so many supporters, it really is a dream come true.
"I will work hard and do everything I can to help this club get back to the top of Scottish football and I am sure next season's Championship campaign will be a successful one."
Rangers manager Ally McCoist added: "Darren is a player we have always liked and appreciated as he is a wholehearted, committed and solid defender.
"He is also very quick and we feel he will be a good acquisition. I watched St Mirren a number of times last year and he was a very consistent performer. He has good experience and it is a tremendous opportunity for Darren to kick on and progress his career."