Josh Scowen netted for Rangers, but the Owls - who had already missed a penalty via Fernando Forestieri - equalised with a Michael Hector spot-kick.
But the visitors grabbed all three points in stoppage time, Matt Smith volleying home.
Lee is out of contract at Wednesday in the summer but has been hampered with injuries.
The 30-year-old's last start came at Carrow Road in December 2017, but Owls boss Steve Bruce named the midfielder in his staring line-up and revealed he wants to keep Lee at S6 next season.
“We want to keep Kieran Lee here, I can confirm that,” said Bruce.
“With a good pre-season under his belt, let’s see if we can get him back to the player we know he is.”
The Owls have released six senior players, whose contracts are up this summer,in Almen Abdi, George Boyd, Gary Hooper, David Jones, Marco Matias and Daniel Pudil.
Four loan players will also return to their parent clubs, Rolando Aarons, Michael Hector, Achraf Lazaar and Josh Onomah.
On the pitch, Bruce named four forwards in his starting line-up in Steven Fletcher, Lucas Joao, Forestieri and Matias in an attacking line-up.
Wednesday had several good chances to open the scoring, but failed to be ruthless in front of goal.
Fletcher and Matias combined to created an eighth-minute chance for Lee, but his effort was blocked.
Matias then broke clear, but one-on-one with the goalkeper Joe Lumley, he tried to play the ball across goal for a team-mate, and the chance was gone.
Rangers defender Daniel Furlong produced a last-ditch tackle to deny Fletcher, after the Scotland striker looked set to score after Joao's pass.
And the hosts were punished for their missed chances, when Scowen was allowed to waltz through the Owls' rearguard before tapping in beyond a stranded Keiren Westwood.
The Owls goalkeeper rushed out to deny Bright Osayi-Samuel from adding a second for Rangers before half-time.
And Westwood thwarted the same player with an even better block at the start of the second half.
Forestieri blasted over a penalty - after the forward was fouled in the box - as chances continued to be wasted by the hosts.
Westwood denied Matt Smith from close-range, the Owls stopper showing the class which has prompted Bruce to offer him a new contract for next season.
And the Irish goalkeeper rescued the Owls from going 2-0 down whe he guessed the right way to save Eberachi Eze's penalty after Osayi-Samuel was fouled by Tom Lees.
Wednesday - playing with 10 men after substitute Sam Hutchinson limped off injured, and all three subs used - levelled from the spot, via Hector, after Matias was fouled.
But in stoppage time, Rangers grabbed the winner as Smith volleyed home.
Owls manager Bruce said: “It was a lacklustre, end-of-season game, a bit like a friendly.
“When you don’t get the basics right, you get punished and we did today. Overall they’ve done very well, but it’s been taken away from us.
“We’ve had a good three months - an OK three months and we have a big summer ahead of us. We have four loans and eight or nine out of contract.
“There’s a big scope here but we need some fresh faces and fresh legs in the squad.”