Dale Gorman's injury-time goal earned Barnet all three points at The Hive to move level with National League leaders Chesterfield.
Only four minutes had been played when Idris Kanu let fly from the edge of the box and saw the ball sail into the top right corner of the net.
But the Magpies were back on terms on 11 minutes as Jayden Mitchell-Lawson struck, with Nicke Kabamba having a header from Anthony Hartigan's delivery well saved soon after.
Courtney Senior shot wide from the edge of the box for the hosts, who saw Jerome Okimo booked on 20 minutes, and then curled just wide of the far post on the half-hour mark.
Zak Brunt became the second Barnet player to be shown a yellow card on 33 minutes, with Harry Pritchard's looping header tipped over moments later.
Laurie Walker produced a stretching save to deny the visitors just before the interval, with Okimo coming to the rescue in the third minute of stoppage time when Maidenhead looked certain to score.
But the respite was brief as the visitors took the lead seconds later as Bradley Keetch struck.
Barnet were back on level terms on 51 minutes, though, as Callum Stead met a brilliant cross to head home.
Maidenhead hit the crossbar and went close in the scramble that followed, with Brunt making way for Gorman in the first Barnet change.
Hartigan fired a free-kick straight at the keeper with 16 minutes left, while Gorman saw a long-range attempt tipped over for a corner.
But Gorman found the net in stoppage time to clinch all three points for Bees, when his whipped cross evaded everyone and found the top corner of the net.
Maidenhead were reduced to 10 men seconds later, when Sam Beckwith was dismissed, to compound their misery.
Barnet: Walker, Okimo, Senior (Hall-Johnson 79), Kabamba, Stead (Hooper 86), Kanu, Pritchard, Hartigan, Wynter, Revan, Brunt (Gorman 72). Unused subs: Barratt, Potter.
Comments: Our rules
We want our comments to be a lively and valuable part of our community - a place where readers can debate and engage with the most important local issues. The ability to comment on our stories is a privilege, not a right, however, and that privilege may be withdrawn if it is abused or misused.
Please report any comments that break our rules.
Read the rules here