The world No 9 from Carmarthen, the runner-up in last year's UK Championship, seized the overnight initiative after O'Sullivan played a suicidal attempt to escape a snooker in the final frame of the afternoon.
Stevens, who defeated O'Sullivan on the way to capturing the Regal Masters in Motherwell last month, had built a 3-1 lead aided by breaks of 67, 62, and 61. O'Sullivan hit back with a 52 break to close the scores at 3-2. But the Welshman, enjoying a beneficial run of the ball and exploiting a series of errors, made 63 to go two frames clear again.
At 4-3, O'Sullivan appeared certain to level the match when he led by 31 with only 27 points available. But his reckless attempt to hit the final red from a snooker let Stevens in for a gutsy 41 clearance to the black and he now requires just four frames for a semi-final place.
Stephen Hendry opened a 5-3 first session lead over Dave Harold, an opponent who has triumphed over the seven-times world champion four times in nine meetings. Hendry levelled at 2-2 with a run of 96 and made breaks of 72, 116 and 92, before an 87 by Harold gave him hope.