A late headed goal from Sotirios Kyrgiakos got Rangers off to a winning start in the Champions League.
Peter Lovenkrands shot Rangers into the lead 10 minutes before the break but Porto hit back after the re-start with Pepe Ferreira's header from a corner.
Rangers replied when Dado Prso got the better of goalkeeper Vitor Baia to bundle in a looping ball but Pepe was allowed to score from another corner.
With five minutes remaining, Kyrgiakos glanced in a Barry Ferguson delivery.
Porto were the more composed team in possession and created the best chances in an end-to-end game but Rangers showed great character to pick up a vital three points.
Manager Alex McLeish will be pleased with his players' battling spirit but the Ibrox side were lucky not to be punished for some shoddy defending.
The visitors started brightly and Rangers survived a few scares in the opening half hour.
After just four minutes, the Portuguese side had forced two corner-kicks, the second of those coming when Alan's drive was deflected just over the crossbar.
There was a big let-off for the home side when Cesar Peixoto delivered a cross for Ricardo Costa but the defender's shot flew too high as he slid in at the back post.
Porto threatened again when Alan burst into the penalty area but his shot struck Ian Murray's outstretched leg and looped over the top.
However, it was Rangers who took the lead against the run of play.
Fernando Ricksen's long ball into the box was missed by both Hamed Namouchi and Pepe but the ball broke to Lovenkrands who hooked in an angled shot from 12 yards.
Ibrox was resonating with cheerful song as the half-time whistle sounded but the home support were silenced soon after the interval.
From a corner in the 46th minute, Pepe rose highest and was allowed to head home from six yards.
Lovenkrands shot Rangers into a half-time lead
It should have been worse for Rangers a few minutes later when Alan and Tomislav Sokota got in each others way as the Rangers defence was posted missing and the latter hit his shot straight at Ronald Waterreus.
Francis Jeffers tried his luck from distance and Wattereus had to deal with a couple of stinging shots before Rangers went ahead again.
After an hour Ferguson's free-kick was met by Kyrgiakos, who nodded into the path of Namouchi.
The Tunisian delivered a high overhead flick to the back-post, prompting an aerial battle between Prso and Baia before the ball came off the knee of the striker and over the line.
But Porto were on level terms after 71 minutes thanks to some more slipshod defending from a corner.
A skiddy delivery was flicked on at the near post and bounced off the chest of Pepe before trundling into the net.
Both teams were going at each other in a rousing finish and it was Rangers who got the vital break when Kyrgiakos stretched to guide in a clever header.
Rangers: Waterreus, Ricksen, Rodriguez, Kyrgiakos, Bernard, Namouchi (Novo 72), Ferguson, Murray, Lovenkrands (Buffel 56), Prso, Jeffers (Thompson 84). Subs Not Used: Klos, Andrews, Alex Rae, Pierre-Fanfan.
Booked: Prso. Goals: Lovenkrands 35, Prso 59, Kyrgiakos 85.
FC Porto: Vitor Baia, Pepe, Ricardo Costa, Pedro Emanuel (Sonkaya 41), Cesar Peixoto, Gonzalez, Diego (Quaresma 64), Ibson, Alan (Hugo Almeida 64), Sokota, Jorginho. Subs Not Used: Paulo Ribeiro, Lopez, Paulo Assuncao, Cech.
Booked: Gonzalez, Hugo Almeida. Goals: Pepe 47, 71.
Ref: Jan Wegereef (Holland).