A tight fourth-round match seemed certain to end goalless until, in stoppage time, the substitute blocked George Friend’s intended clearance and the ball flew into the back of the net.
It was a tough result to take for Boro who were the better team for long spells.
Middlesbrough had the better of the early exchanges and Martin Braithwaite headed Friend’s cross over the bar before Ashley Fletcher fired a shot wide after being set up by Adama Traore.
As Tony Pulis’ team continued to dominate proceedings Daniel Ayala’s header was kept out by Tim Krul in the Seagulls goal.
Patrick Bamford’s acrobatic effort then flew over Krul’s bar and, just before half time, Traore blasted a shot against the woodwork after being set up by Fletcher.
Chris Hughton’s team improved after the interval but, after he had spilt Baram Kayal’s long-range effort, Darren Randolph made a good block when Jiri Skalak tried to turn the rebound home.
Boro continued to look dangerous when they burst forward though and Traore, with a 20-yard drive, and Friend, whose left-footed strike was blocked, went close to breaking the deadlock.
Substitute Stewart Downing lashed another effort narrowly wide while, after a rare Seagulls attack, Jose Izquierdo fired his shot straight at Randolph.
But as the match moved into stoppage time Murray struck in fortuitous circumstances to send Brighton into the fifth round.
Uwe Rosler was sacked by Fleetwood following a 3-0 reverse at Doncaster which condemned Town to a seventh straight defeat in all competitions.
Cambridge interim head coach Joe Dunne was pleased with how his side adapted to beat Grimsby 3-1.
Southend manager Chris Powell led the applause for Jason Demetriou after the right-back scored twice in the 3-1 win against Portsmouth at Roots Hall.
Morecambe boss Jim Bentley was the happier manager after Gregg Wylde's 90th-minute strike earned his side a point in their 1-1 draw with Forest Green.
Manager Gareth Ainsworth described Wycombe's 2-0 win at Cheltenham as a thoroughly professional performance.
Skipper Richard Wood scored the winner just before half time as in-form Rotherham pulled off a 1-0 victory at League One leaders Shrewsbury.