Lilley's previous best ranking showing was at the 2016 Indian Open, where he fell to Shaun Murphy at the quarter-final stage having beaten Mark Williams and Robert Milkins.
However, the win against Ding represents 44-year-old Lilley’s first success since turning professional in September.
Lilley, who will face Jamie Rhys Clarke or Ben Woollaston in round two, took a three-frame advantage and in doing so put himself within one frame of victory behind runs of 96, 82 and 84.
What If...? | Mark Selby
However, Ding a 13-time ranking title winner, rallied cutting the arrears by taking frames four and five but Lilley produced a fourth 50-plus break – this time 71 – to condemn Ding to defeat.
Earlier, Mark Selby, winner of the English Open in Crawley, beat Xu Si 4-2 to make round two.
The three-time world champion produced runs of 78, 64 and 73 on his way to victory over the world number 97 Xu.
Elsewhere, Yan Bingtao and Ali Carter are also into the second round after victories against Andy Hicks and Robert Milkins, respectively.
What If...? | Shaun Murphy
Thepchaiya Un-Nooh battled fatigue to beat Mark King 4-2, while Zhang Anda holds the highest break so far with a 139 in his 4-1 win over Simon Lichtenberg.
In the evening session, John Higgins held off a spirited fightback from Chang Bingyu to set up a potential second-round clash against Riley Parsons or Kacper Filipiak.
Higgins opened up a three-frame advantage courtesy of runs of 63 and 55 but Chang, ranked 92 in the world, produced breaks of 105 and 74 to cut the arrears.
However, four-time world champion Higgins closed out the victory with a 51.
Shaun Murphy coasted into the second round with runs of 80, 95 and 76 against Fraser Patrick in the late match on the show table.
NORTHERN IRISH OPEN ROUND ONE RESULTS
- Shaun Murphy 4 - 0 Fraser Patrick
- Jackson Page 4-3Barry Pinches
- Barry Hawkins 4 - 3 Eden Sharav
- Ian Burns 4 - 0 Andy Lee
- Alexander Ursenbacher 4 - 2 Xiao Guodong
- John Higgins 4 - 2 Chang Bingyu
- Hammad Miah 4 - 1 Martin Gould
- Robbie Williams 4 - 1 Anthony McGill
- Anthony Hamilton 4 - 3 David B Gilbert
- Jordan Brown 4-2 James Wattana
- David Lilley 4 - 2 Ding Junhui
- David Lilley 4 – 2 Ding Junhui
- Chen Feilong 4 - 2 Kishan Hirani
- Mark Davis 4 - 2 Mike Dunn
- Thepchaiya Un-Nooh 4 - 2 Mark King
- Mitchell Mann 4 - 1 Liam Highfield
- Mei Xiwen 4 – 1 Peter Lines
- Rod Lawler 4 - 1 Ashley Carty
- Mark Selby 4 - 2 Xu Si 
- Harvey Chandler 4 – 1 Ryan Day
- Andrew Higginson 4 – 0 Tom Ford
- Stephen Maguire 4 – 0 Declan Lavery
- Ken Doherty 4 - 2 Michael Georgiou
- Jak Jones 4 – 1 Thor Chuan Leong
- Yan Bingtao 4 - 2 Andy Hicks
- Li Hang 4 – 1 Elliot Slessor
- Zhang Anda 4 – 1 Simon Lichtenberg
- Allister Carter 4 - 1 Robert Milkins
- Si Jiahui 4 – 0 Hossein Vafaei
- Tian Pengfei 4 – 1 Lü Haotian
- Matthew Stevens 4 – 1 Chris Wakelin
- Marco Fu 4 – 1 Gerard Greene