The Millers have beaten off competiton from League One clubs to have signed 24 year old Ainsworth.
Talks had taken place with the right winger previously but gaffer Steve Evans tells the official site themillers.co.uk that he thought the deal was deal up until the weekend.
"I'm glad we've signed Lionel, as he's an exciting winger with frightening pace. He's a matchwinner and someone I look forward to working with. We've added something we didn't have, which is a winger who had sheer pace, and any defender will tell you they don't want to play against someone like that."
"We've tried for four or five weeks to sign him and I thought he was off to League One as late as Friday evening, but thankfully for us he got stuck on the M25 for six or seven hours, and I think that made his mind up.
"My final call was to Ian Sharps; I called him on Saturday morning, and he said to get in the car and go get him."