The 19-year-old Serb overcame a back injury to overpower the world number 102 in the first two sets and he served for the match at 5-4 in the third.
But a succession of unforced errors allowed Udomchoke a foothold in the match, and the 25-year-old won three games in a row to become the first man to take a set off Djokovic in the tournament.
Djokovic retained his composure to make an early break in the fourth set and took Udomchoke's serve two more times, the Serb clinching victory in two hours 45 minutes with a delightful drop shot.
Djokovic will play top seed Roger Federer or Russian Mikhail Youzhny in the last 16.
Reuters AY GC1004