In the Middle Ages the current town's territory was divided between Veprinac (now a locality of Opatija, perhaps home to a small fishing port) and Kastav, where the fisherman village of Veprinac. The small hamlet of Opatija itself developed around a Benedictine abbey dedicated to Saint Jacob, which was first mentioned in 1453. While western Istria was gradually conquered by the Republic of Venice by 1420, the remaining territory up to Opatija fell to the House of Habsburg and later was incorporated into the Austrian Littoral.