Trailing 2-0 from the first leg against the Irish club Longford, Carmarthen scored four second-half goals to win 5-1 on the night and 5-3 on aggregate.
Carmarthen signalled notice of their intentions when Daniel Thomas opened the scoring. But the FAI Cup holders Longford equalised from the penalty spot through Andrew Myler to restore their two-goal advantage and they looked to be in control of the tie.
However, the home side threw caution to the wind after the break and hit the visitors with a four-goal blitz. Gary Lloyd struck twice, then Thomas added his second before Nathan Cotterall sealed the win 10 minutes from time.
Lloyd admits even he was stunned by his side's comeback. "I thought the game was all over to be honest," he said. "But it was a great performance by the boys in the second half." The Welsh club are at home first on 11 August, with the away leg two weeks later.
Dundee United booked their place in Europe by reaching last season's Tennent's Scottish Cup final, where they were beaten by Celtic.
The tie against the Finns, whom Liverpool knocked out of the Cup Winners' Cup in 1996, will represent an early test for United's manager Gordon Chisholm, who guided the club to the cup final after replacing Ian McCall, who was sacked in March. The former Sunderland defender was handed the position on a permanent basis in May and is preparing for a first full SPL campaign.
The Tannadice club have not played in European competition since being defeated by Trabzonspor in the Uefa Cup qualifying round seven years ago.
United were Uefa Cup finalists in 1987 though, losing to Gothenburg in a two-leg final under legendary manager, Jim McLean. The Tayside club also reached the European Cup semi-finals in 1984.
Cork, 2-1 aggregate winners over Lithuanian league leaders FK Ekranas, travel to Sweden to face Djurgarden in the first leg of the next round. Rhyl face Norwegian team Viking, who are managed by the former Internazionale and Blackburn manager Roy Hodgson, and Irish League side Linfield face Halmstad of Sweden.
Uefa Cup draw
Second Qualifying Round
APOEL Nicosia (Cyp) v Maccabi Tel Aviv (Isr)
Austria Vienna v Zilina (Slovak)
Banants Yerevan (Arm) v Dnipro Dnipropetrovsk (Ukr)
Bashkimi Kumanovo (Maced) v Maccabi Petah Tikva (Isr)
Domzale (Sloven) v Ashdod (Isr)
Carmarthen v FC Copenhagen (Den)
Dynamo Bucharest (Rom) v Omonia Nicosia (Cyp)
Djurgarden (Swe) v Cork City
Groclin Grodzisk (Pol) v Dukla Banska Bystrica (Slovak)
Esbjerg (Den) v Tromso (Nor)
Litex Lovech (Bul) v Rijeka (Croa)
Midtjylland (Den) v Torshavn (Faroe Is)
Sopron (Hun) v Metalurg Donetsk (Ukr)
Pasching (Aut) v Zenit St Petersburg (Rus)
FC Vaduz (Liecht) v Besiktas (Tur)
Mainz (Ger) v IBK (Ice)
Halmstad (Swe) v Linfield
Inter Zapresic (Croa) v Red Star Belgrade (Serb-M)
Krylya Sovietov Samara (Rus) v BATE Borisov (Bela)
Legia Warsaw (Pol) v FC Zurich (Swit)
Lokomotiv Plovdiv (Bul) v OFK Belgrade (Serb-M)
Metalurgs Liepaja (Lat) v Racing Genk (Bel)
MTZ-RIPA Minsk (Bela) v Teplice (Cz Rep)
MyPa Myllykoski (Fin) v Dundee Utd
Nistru Otaci (Mol) v Graz AK (Aut)
Publikum Celje (Sloven) v Levski Sofia (Bul)
Brann Bergen (Nor) v
Allianssi Vantaa (Fin)
Vardar Skopje (Maced) v Rapid Bucharest (Rom)
Viking Stavanger (Nor) v Rhyl
Wisla Plock (Pol) v Grasshoppers (Swit)
Zeta Golubovci (Serb-M) v Siroki Brijeg (Bos)
First legs to be played 11 August, with second legs on 25 August
- More about: