The Magpies took the lead early on through Joselu, but goals from Riyad Mahrez and Demarai Gray either side of half time turned the match in Leicester’s favour heading into the final 30 minutes.
Dwight Gayle looked to have rescued a point for Rafael Benitez’s side with an equaliser 17 minutes from time, but Perez’s late own goal saw the home side stretch their winless run to seven matches, leaving them just two points clear of the relegation zone.
Leicester, meanwhile, climb up to eighth place having now won three consecutive matches for the first time since April, keeping them a healthy 10 points clear of the bottom three.
The hosts have now picked up just one point from the last 21 on offer, but they wasted no time in breaking the deadlock as Joselu opened the scoring after less than five minutes.
Gayle advanced down the left flank before pulling the ball back for the Spaniard, who swept his finish past Kasper Schmeichel to gift Newcastle a perfect start to the match.
It could have got even better when the hosts were close to making it two goals in as many minutes shortly afterwards, but Gayle strike across goal fizzed narrowly wide of the far post.
Leicester soon began to pose an attacking threat of their own, though, with Demarai Gray leading the charge as he drew a low stop from Karl Darlow and then flashed a second effort over the crossbar in quick succession.
The Foxes continued to knock on the door with Wilfred Ndidi the next to come close before Gray sent another strike narrowly off target, and that pressure eventually told with the equalising goal after 20 minutes.
Mahrez was the man to restore parity, continuing his good recent form in the final third to beat Darlow from outside the box, despite the keeper getting a hand to the ball.
Having spent the opening stages on top, Newcastle suddenly found themselves on the back foot and Marc Albrighton, Jamie Vardy and Danny Simpson all came close in the space of just six minutes straight after the equalising goal.
The Magpies then survived a penalty shout following DeAndre Yedlin’s challenge on Vardy inside the box, with referee Neil Swarbrick waving the claims away.
Vardy had another effort which flew off target before Newcastle finally began to test the Leicester defence again, although Gayle could not sort his feet out in the penalty area and Jacob Murphy was denied by Schmeichel moments later.
Schmeichel had more work to do with just six minutes remaining in the first half when Matt Ritchie powered a firm free kick towards goal, but it was straight at the Leicester keeper and he was able to collect it at the second attempt.
The second half began in a calmer manner than the first, but the third goal of the game did finally arrive on the hour mark via a large slice of fortune for the visitors.
Gray had looked like Leicester’s most likely attacking threat throughout, and he got his goal via a big deflection off Florian Lejeune as his effort flew past Darlow and into the roof of the net.
Leicester continued to push on for a two-goal cushion, but Mahrez was denied by Darlow and that proved to be an important stop as Newcastle went on to level things up just seven minutes later.
Gayle added a goal to his assist from earlier in the match, cutting inside before arrowing his finish into the bottom corner past Schmeichel.
Gayle almost added a quickfire second just five minutes later, but this time his strike flew narrowly past the post as Newcastle continued to look for a much-needed winning goal.
It was a Magpies player who ultimately scored the winner, but it came at the wrong end as Perez inadvertently turned the ball past his own goalkeeper after tracking back and dispossessing Shinji Okazaki inside the penalty area.
Newcastle failed to respond despite five minutes of injury time being signalled by the fourth official, with the result seeing Benitez lose three consecutive home games for the first time in the Premier League.
The Magpies are without a win since October 21, picking up just one point in their last seven outings whereas Leicester have now won three on the bounce under Claude Puel.