The on-loan Rotherham winger hit a superb long-range strike in the 76th minute after Dundee United had cancelled out Henri Anier’s opener with two goals in four minutes early in the second half.
Anier’s well-executed volley had given the visitors a deserved lead on the half-hour mark but United soon got into their stride.
Each team had come into the match on form with Motherwell on a three-match winning streak and United having hit 11 goals in their previous four games and they both pushed for a winner in an exciting finale.
The breakthrough came as a result of a powerful run down the left wing by Zaine Francis-Angol in a move which justified his inclusion ahead of James McFadden.
The left-winger got away from Ryan Dow just inside United’s half and got to the penalty box before cutting across John Rankin to cut the ball back.
The delivery was far from easy for Anier to take but the on-loan Viking Stavanger forward chested the ball down and repositioned his body perfectly to fire a powerful left-footed volley beyond Radoslaw Cierzniak’s outstretched hand.
United stepped up a gear after half-time and equalised in the 53rd minute after Motherwell had defended a series of corners.
With Ramsden breaking down the right, Keith Lasley and then Shaun Hutchinson saw balls forward cut out. Ciftci peeled into the space on the left and collected the pass from John Rankin to fire an angled drive underneath Lee Hollis and into the net.
Anier had a 20-yard curler held before making way for McFadden, but it was the other substitute who immediately stole the show.
Ainsworth controlled a second ball from a Hollis goal kick and fired a powerful 25-yard strike inside Cierzniak’s near top corner.
United manager Jackie McNamara made an ambitious double switch as he brought on strikers David Goodwillie and Brian Graham for Dow and Ryan Gauld, while moving Ciftci to wide right.
But Motherwell were not satisfied with a point either and Sutton headed just wide following an up-and-under in the 89th minute before Goodwillie elected to head the ball back to a team-mate when presented with a stoppage-time chance.