The 25-year-old, who began his career with Derby County in 2006, has not featured for the Millers this season.
The winger has agreed a switch to the Scottish Premiership club until January.
"I am very pleased to be here," Ainsworth told Motherwell's official website.
"It's great to have joined a big club in Scotland. I am really looking forward to it, meeting the players and meeting the fans.
"It is going to be something different for me but I am going to embrace it and do everything I can to make everyone happy."
Ainsworth has made 18 appearances for Rotherham since joining the club in 2012.