Second-half goals from Scott McCulloch and Mark Roberts helped Thistle to a deserved win at Somerset Park.
Ayr had led through Gareth Wardlaw's first-half header, but spent large amounts of time defending as Thistle created a host of good chances.
The visitors missed a ninth-minute sitter which set the tone when Paul Ritchie headed wide from just five yards.
Ayr punished the miss when Wardlaw stooped to head home Craig Conway's cross and give United a half-time lead.
But Thistle rose back after the break, and ex-Ayr defender McCulloch rifled home a 25- yard free-kick to level.
Mark Roberts then grabbed the winner when he slotted home after a Ritchie shot was blocked by the Ayr defence.
It was end to end from there, and both sides went full throttle in the closing stages.
Ayr came close to a dramatic late equaliser, but Chris Robertson's shot was superbly tipped round the post by Kenny Arthur.
Partick boss Dick Campbell said: "It's the seventh time we've come from behind this season and shows the resilience of the team."
Ayr manager Robert Connor said: "We're disappointed because at 1-0 up we should have gone on to win."