Diniyar Bilyaletdinov's brace seemed to have put the home side in command but Pecnik - introduced in the 83rd minute in place of Andraz Kirm - pounced two minutes from time for a potentially crucial away goal.
"It's always disappointing when you allow your rivals to score a goal at the very end but we can only blame only ourselves for it," said Russia boss Guus Hiddink.
"We had plenty of chances to increase our lead but missed them, while Slovenia converted one of their rare chances into a goal. But I believe we will score in the away match and clinch a place in the World Cup finals."
A capacity crowd of 80,000, which included Russian prime minister Vladimir Putin, had been issued with protective masks to guard against swine flu in the Luzhniki Stadium.
Zhirkov, included despite an injury-hit start to his Chelsea career, then set off from his own half and tricked his way into the heart of the Slovenia penalty area, but his shot was repelled by the feet of goalkeeper Samir Handanovic.
Marko Suler's precise lofted pass then put Zlatko Dedic in behind the home defence. He was forced wide by Igor Akinfeev, however, and his weak shot went through the goalkeeper's legs but wide of the near post.
Sergei Ignashevich's fierce low drive from a 30-yard free-kick saw Handanovic again save with his legs, and Ignashevich made an important challenge as Dedic looked to break before Russia conjured an excellent 41st-minute opener.
Roman Pavlyuchenko's neat pass with the outside of his foot found Bilyaletdinov on the edge of the box and the Everton midfielder beat centre-halves Suler and Bostjan Cesar with a superb drag-back before finishing powerfully with his weaker right foot.
Two Zhirkov crosses then saw Andrey Arshavin head wide before Pavlyuchenko's weak effort was blocked by Cesar. Handanovic then tipped over another Ignashevich rocket but Russia went 2-0 up in the 52nd minute.
Bilyaletdinov got in the way of Arshavin's cross for Sergey Semak, but finished calmly when the ball ricocheted back to him off Konstantin Zyryanov. Bilyaletdinov went close to his hat-trick as a late header flashed wide and Pecnik shot wide after Novakovic's mishit volley bounced to him.
But the substitute was on hand a minute later to head home from close range after Akinfeev tipped away Robert Koren's shot, Slovenia's first on target in the 90 minutes.
And Suler could even have equalised for the visitors in stoppage time, popping up unmarked at the back post to force a superb diving save from Akinfeev.
"I'm unhappy with the result but it's better to be wounded than dead," said Slovenia supremo Matjaz Kek.
"This defeat leaves us chances to qualify for the finals. The last minutes tonight proved we still have spirit to win. I'm confident that at home we will have luck on our side."