Lee Tomlin's curling 28th-minute opener in Saturday's Championship clash at Selhurst Park was cancelled out by a Glenn Murray penalty shortly before half-time.
Nathaniel Mendez-Laing put the visitors ahead again after 63 minutes but the Eagles won the game through late goals from Kevin Phillips and Mile Jedinak - sending Darren Ferguson's side down.
Posh were just minutes away from safety until Jedinak popped up at the death to win it for Palace and send their visitors into the bottom three owing to Barnsley's 2-2 draw at Huddersfield.
It was heart-breaking for Peterborough as it was just their second defeat in the last 13 games and ends a two-year stay in the second tier.
For Palace, it was their first victory in nine and confirms a play-off place, with a two-legged semi-final against Brighton next week.
It was a strong start by Palace and Peterborough were grateful to Grant McCann for saving their skin after 11 minutes as he cleared off the line from Murray.
Posh took the lead when Tomlin picked up the ball on the left hand side, went on a surging run, beating three players and curling through a crowded box into the bottom corner.
But their relief was short-lived as Palace levelled in first-half stoppage time. Daniel Gabbidon was fouled by Gabriel Zakuani following a corner and Murray finally got back on the scoresheet by despatching the resulting penalty.
In a dramatic afternoon, things swung in Peterborough's favour again shortly after the restart as Huddersfield levelled to send Barnsley back into the bottom three, but Ferguson's men were living dangerously.
Murray was close to doubling his tally following good work from Wilfried Zaha, but Tommy Rowe superbly cleared the ball off the line.
But just after the hour mark, Posh took their destiny back into their own hands as they regained their lead. Mendez-Laing cut in from the right and curled an effort that bounced just in front of Julian Speroni and nestled in the bottom corner, with the Palace keeper disappointed not to do better.
With the game at Huddersfield progressing to 2-2, it looked as if Posh would be safe, though their nerves were jangled when Phillips struck from 18 yards to also level at 2-2.
But the decisive moment came with just a minute of normal time remaining when Jedinak headed home Stephen Dobbie's cross to break Peterborough hearts and end Palace's barren run.