The Seasiders left it late to beat the Latvian side 2-1 on the night at Daugava Stadium, scoring in injury-time to level the tie at 3-3 on aggregate and force penalties.
Andy Parkinson proved to be the Prestatyn hero, the midfielder netting the deciding kick to wrap up a 4-3 victory in the shoot-out.
Having lost the first leg at home, the Welsh side faced a sizable challenge even before they conceded a goal early on during the return fixture.
Valerijs Afanasjevs put the hosts one up on the night on 17 minutes but Prestatyn dug deep and Ross Stephens pulled a goal back with 13 minutes remaining.
That provided the platform for Neil Gibson to pounce in injury-time and send the tie into extra-time.
The additional period failed to provide any further goals and the tie went to a shoot-out.
Former Tranmere and Grimsby midfielder Andy Parkinson netted from 12 yards with the score at 3-3 and when Davis Ikaunieks missed with the next kick, Prestatyn sealed a thrilling win.
The Welsh side move through to meet HNK Rijeka in the second round.
Otherwise, it was a miserable night for British and Irish clubs in the competition.
Fellow Welsh sides Bala Town and Airbus UK both went out, Bala losing 3-2 on aggregate to Levadia Tallinn of Estonia and Airbus going down on the away goals rule following a 0-0 draw with Latvian side Ventspils. The first leg in Flintshire had finished 1-1.
League of Ireland side Drogheda were bounced out by Swedish side Malmo, 2-0 winners on the night and on aggregate, while Northern Ireland outfit Crusaders were thumped 7-2 by Rosenborg of Norway, who completed a 9-3 aggregate win.
Belfast side Glentoran's interest in the competition was ended by a 3-0 defeat to Iceland's Reykjavik following a goalless first-leg draw and Dublin side St Patrick's Athletic were also eliminated after losing 2-1 at home to Lithuania Zalgiris, who sealed a 4-3 win on aggregate.
- Sports & Recreation
- Andy Parkinson