The 28-year-old, whose deal at Ibrox includes the option for a further year, becomes Rangers' second signing of the summer following the arrival of striker 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."
McGregor spent four years with St Mirren in the Scottish Premiership after leaving Cowdenbeath in 2010.
Rangers manager Ally McCoist said: "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."