The Fife town is on the list for its “expansive beach” and “characterful buildings”, as well as its “renowned golf course.”
The Old Course contributed to a five-star score in the survey for best tourist attractions.
The study interviewed 3,000 visitors, asking them to rate their experiences of visiting seaside towns in the last year.
Criteria included quality of the beaches, food and drink offerings, tourist attractions and value for money.
The historic university town, which has recently been a film set for cast and crew from the Netflix hit The Crown, came in joint fourth with Portmeirion, in Gwynedd, and Tynemouth, in Tyne and Wear, with an overall score of 83 per cent.
Portmeirion was praised for its “quirky” appeal, while respondents enthused over the “beautiful” beaches in Tynemouth.
In first place, for the third consecutive year, Northumberland’s Bamburgh secured a score of 88 per cent, with five stars for scenery, quality of its beach and peace and quiet.
In second place, and with a score of 85 per cent was Dartmouth, in Devon.
The southern spot was given five stars for scenery and accommodation, with one respondent complimenting the town’s “atmosphere and vibrancy.”
In third place, and for the first time on the Which? survey of best UK coastal towns, was Portstewart in Derry/Londonderry with an overall score of 84 per cent.
Visitors praised the “fantastic beach” as well as the selection of cafes “selling home-style baking.”
At the other end of the table, Clacton-on-Sea and Skegness tied in last place with a score of 48 per cent, closely followed by Burnham-on-Sea and Bangor with scores of 49 per cent.
Despite lower scores, some respondents commented on Clacton’s “lovely” seafront gardens and praised its “fantastic” annual airshow.
Skegness also drew praise for its "old fashioned” charm, with plenty of entertainment for children, from donkey rides on the beach to an aquarium and arcades.Visitors to Burnham-on-Sea found a “gentle" resort, with the opportunity to enjoy a traditional chippy tea.
And in Bangor, holidaymakers praised “fabulous views” from the pier and the town’s “wonderful” Cathedral.
Rory Boland, Editor of Which? Travel, said: “Few countries can be home to such a diversity of brilliant seaside breaks as Britain. Whether you want world class beaches and utter wilderness or the bright lights and bucket and spade atmosphere of a resort, the UK has a seaside break made for you.
“What our survey shows is that it’s rarely the most famous destinations that visitors enjoy most. Try somewhere new this year and our survey shows you should find fewer crowds and better value."