O'Sullivan had raced into an early two-frame lead at the Centaur in Cheltenham and looked set to inflict another whitewash like he managed against Barry Hawkins in round one.
Red-haired Saengkham fought back impressively though with three half-centuries helping him send O'Sullivan packing with a 4-2 win after knocking out Mark Selby on Tuesday.
"I am feeling over the moon," 24th seed Saengkham told World Snooker Tour after potting the pink at the second time of asking to seal a fourth consecutive frame and victory.
"Ronnie is like a hero of all the snooker players and it is not easy to beat him but actually I had to beat my heart first because when we are paired with him, we already lost half (the battle) so I had to beat my heart first.
"Yeah the first shot when I get a chance on pink and I miss, then the second chance I just try say to myself, 'I believe in you,' because my daughter's name is believe so I said I needed to pot the pink to win it and I got it."
Next up for the Thai player is a last-eight meeting with Masters runner-up Mark Williams, who continued his good form with a 4-0 victory over Ding Junhui.
Jack Lisowski booked his quarter-final berth with a 4-2 win over Zhou Yuelong while Mark Allen edged a seven-frame thriller with Joe O'Connor.
Earlier in the day, Shaun Murphy whitewashed Ali Carter to progress into the last-16 while Sam Craigie got the better of Tom Ford 4-2.
Luca Brecel and Anthony McGill were also 4-1 winners over Joe Perry and Gary Wilson respectively to conclude the first-round action.