The Lions, who face Wigan in the FA Cup semi-final on Saturday, got off to the perfect start when Jimmy Abdou scored after just 63 seconds of Tuesday night's Championship clash at The Den.
But Wednesday equalised through Miguel Llera's free-kick before the interval, and substitute Maguire struck in stoppage time as the Owls moved six points clear of the bottom three.
It brought an end to Millwall's three-game unbeaten run and means they are not out of the woods themselves yet. However, for the time being, they can focus on Wigan and potentially 90 minutes from a place in Europe.
They are unlikely to find the Latics as charitable as Wednesday, who conceded the opener with the first attack of the match. Chris Taylor was allowed to cut in from the left wing, charge into the penalty area unchallenged and deliver a low cross for the unmarked Abdou to bundle home at the far post.
It was recalled midfielder Abdou's first home goal for the Lions, five years since he joined, and the perfect way to stake his claim for a Wembley appearance.
Millwall were certainly not playing like a team with their minds elsewhere, though, and continued to bombard Wednesday's goal. Rob Hulse burst into the area but could not get round Owls keeper Chris Kirkland, and Shane Lowry fired narrowly wide.
Wednesday had barely threatened in the opening half hour, apart from a close-range effort from Steve Howard which was well saved by David Forde.
But five minutes before half-time they drew level through Llera, who curled a 25-yard free-kick around the wall. Forde appeared to have the shot covered, but the ball bounced in front of him, over his hands and into the net.
Taylor could have put Millwall back into the lead on the stroke of half-time but his backheel from Lowry's cross flew straight at Kirkland.
The Lions had a let-off moments after the interval when a half-cleared corner fell to David Prutton on the edge of the area and his shot was cleared off the line by Lowry.
Both sides had chances late on with Jermaine Easter firing wide and Kirkland denying Taylor and Sean St Ledger with fine saves, while referee Phillip Gibbs waved away some strong Millwall penalty appeals after Seyi Olofinjana appeared to handle.
Wednesday sub Jermaine Johnson should have put the visitors ahead 10 minutes from time but fizzed his shot narrowly wide.
However, the winner came deep into four minutes of stoppage time when Maguire hooked in Danny Pugh's corner to seal a valuable three points.