Record signing Alexandre Lacazette put Arsenal ahead after only 85 seconds at the Emirates Stadium, before a Shinji Okazaki header and a Jamie Vardy brace saw 2016 champions Leicester go 2-1 and then 3-2 up.
But Arsene Wenger's double change turned the game, FA Cup final hero Ramsey drilling in an 83rd-minute equaliser and Giroud notching the winner two minutes later with a header that hit the bar and bounced over the line.
The Ramsey-Giroud rescue act spared Arsenal from a fourth season-opening defeat in five campaigns and enabled Wenger to start the season with victory for only the second time in eight years.
The Arsenal manager faced open dissent from fans last season as his side missed out on a place in the Champions League for the first time in 20 years.
But after winning a record seventh FA Cup with victory over Chelsea, he penned a new two-year contract and his side's Houdini act against Leicester means that late-season momentum remains intact, albeit only just.
The fans at the Emirates were getting their first glimpse of Lacazette in a competitive game and the £46.5 million ($60.3 million, 51.1 million euros) man needed less than two minutes to find the net.
From Hector Bellerin's lay-off, Mohamed Elneny swept a first-time cross into the box and Lacazette deftly glanced a header past Kasper Schmeichel before spreading his arms to take the acclaim of the crowd.
Within three minutes Leicester were level. Following a short corner on the left, Marc Albrighton's deep cross was headed back across goal by Harry Maguire and Okazaki leapt to nod a header past Petr Cech.
- Arsenal reshuffle -
Arsenal stepped things up, Schmeichel saving from Alex Oxlade-Chamberlain and home debutant Sead Kolasinac, but they were careless in possession and shortly before the half-hour, Leicester went in front.
Granit Xhaka's sloppy pass was picked up by Albrighton and he forged down the left flank before bending a sublime cross into the danger area that Vardy tapped home.
"We're gonna win the league!" sang the Leicester fans and they almost had a third goal to cheer when Okazaki's header from Christian Fuchs's cross bounced just wide of Cech's left-hand post.
After Wilfred Ndidi had survived a penalty shout for handball, Arsenal levelled in first-half stoppage time, Danny Welbeck tapping in from Kolasinac's square pass after Lacazette's shot was blocked.
Though Arsenal began the second half on the front foot, Leicester created the cleaner chances, Cech rushing out of his box to tackle Vardy and then tipping over a shot by Riyad Mahrez, and after 11 minutes they went in front again.
Again a set-piece proved Arsenal's undoing as Mahrez's in-swinging corner from the right was nodded in by Vardy.
Schmeichel thwarted Oxlade-Chamberlain and Bellerin before Wenger turned to his bench in the 67th minute, pitching Ramsey and Giroud into the fray in place of Elneny and Rob Holding.
The ensuing reshuffle left Arsenal with a winger -- Oxlade-Chamberlain -- at right-back, a right-back -- Bellerin -- at left-back and two left-backs -- Kolasinac and Nacho Monreal -- at centre-back.
It seemed an unlikely platform for victory, but Ramsey neatly controlled Xhaka's dinked pass to drill in an equaliser and moments later Giroud's header from Xhaka's corner completed a remarkable turnaround.