The 26-year-old winger was on loan from Rotherham last season and scored 11 goals for the Steelmen with 12 assists to help them finish runners-up to Celtic in the Scottish Premiership for the second consecutive season.
The Fir Park club claimed to have seen off competition for Ainsworth's signature from north and south of the border, and overseas
After signing his new deal with the Lanarkshire side, the Englishman told MTV: "I'm very happy. I've had a summer thinking about what's going to happen and to be honest I never wanted to leave.
"I'm happy to have it sorted and I love the club. In the short space of time I've been here everyone in and around the club have been brilliant and I feel at home here.
"I managed to hit the ground running last year and hopefully I can carry that on to next season.
"It would be amazing if I could score more goals next season and get more assists but I know I have to go out there and give my all to keep my spot in the team.
"We achieved great things last year and I'm sure we can go out and do it again."
Motherwell boss Stuart McCall was delighted to secure the services of Ainsworth, not least because it is "another piece of our summer transfer work taken care of early".
"He made such a massive contribution last season, particularly around the Christmas and New Year period when he was flying high and practically unplayable in certain games," said the former Bradford manager.
"To have such a scoring threat from midfield is vital for any side, but he also contributes by creating goals for our strikers.
"With a strong pre-season behind him and the platform of playing in the Europa League to look forward to, it should be a big season for him."
Meanwhile, defender Shaun Hutchinson ended his association with Motherwell by joining Fulham on an initial two-year deal.