Clint Dempsey struck for Tottenham in the 76th minute with the help of a deflection off Everton defender Sylvain Distin and that goal looked set to win it for the north London side.
But David Moyes' men snatched a deserved victory thanks to an equaliser from South Africa midfielder Pienaar in the 90th minute and Croatia striker Jelavic's winner in the second minute of stoppage-time.
The sensational finale lifted Everton above Tottenham on goal difference and ended a run of three successive wins for Andre Villas-Boas's side.
After seven draws from the last nine, Everton desperately needed a win and their cause was aided by the return from injury of Belgian forward Kevin Mirallas, who was instrumental in the early exchanges.
Mirallas created a chance for Leon Osman but the England international saw his shot blocked by William Gallas.
Darron Gibson, who had been playing some sublime passes, slipped Seamus Coleman down the right and he crossed for Jelavic, but Tottenham goalkeeper Hugo Lloris blocked the forward at the near post.
Tottenham threatened with a powerful low effort from Mousa Dembele that was just too close to Tim Howard.
Jelavic, who has only managed one goal in his last eight outings, found himself clean through on Lloris in the ninth minute.
But as the Croatian went to round Lloris, the Frenchman managed to get his hands on the ball to divert it away from danger.
Moyes, in his pre-match programme notes, called for an improvement from the Premier League's match officials after a number of decisions went against his sides in recent time.
And the Scot will have been furious again after referee Kevin Friend turned away two penalty shouts before the break.
First Dempsey appeared to use the top half of his arm and shoulder to control the ball in his own area.
Then Pienaar's cross seemed to be blocked by Gallas' arm, but again Friend shook his head while Moyes went mad on the touchline.
Mirallas had to make way at half-time as he tweaked his hamstring but his replacement Steven Naismith missed a glorious chance within a minute of the restart.
Leighton Baines' free-kick flew into the wall and his follow-up deflected into the path of Naismith who was free on the right but he side-footed wide.
Jan Vertonghen gave Everton goalkeeper Howard his first test of the second half as the American had to palm over a rasping free-kick from the Tottenham full-back.
Osman forced another good stop from Lloris with 15 minutes to go as the game looked destined to end in a draw despite all Everton's dominance.
But a minute later, Tottenham went ahead against the run of play as Dempsey hit a speculative effort goalwards that deflected off Everton defender Distin and found the back of the net after looping over Howard.
Just as it looked like a cruel defeat for Everton, Coleman crossed into the area and Pienaar dived in to head past Lloris.
Then two minutes into the four minutes of stoppage-time the ball fell kindly to Jelavic in the Spurs penalty area and he showed great composure before firing past Lloris.