The 24-year-old has signed a contract until summer 2017 and joins the League One club for an undisclosed fee.
“Shane has displayed his ability in two different positions for us since he joined on loan, so naturally I’m delighted that he is now with us on a permanent basis,” Millwall boss Neil Harris told the club’s official website.
“He has shown a real desire to stay here and is of an age where he needs to be playing football regularly for the sake of his own development, and we have given him that opportunity.
“I believe that it is a fantastic piece of business and I would like to thank the board for giving me the opportunity to buy a player of Shane’s quality and age.”
“It’s a relief to get the deal done,” Ferguson said. “I’ve been keen to get everything sorted and I’m now really looking forward to my future with Millwall.
“I’ve loved every second of my time here so it was a no-brainer to sign on a permanent basis.
“My task now is to help Millwall get back to where we belong, which hopefully can be done this season.”