In this paper we present a comprehensive framework for measuring similarity within and between ontologies as a basis for the interoperability across various application fields. In order to define such a framework, we base our work on an abstract ontology model that allows adhering to various existing and evolving ontology standards. The main characteristic of the framework is its layered structure: We have defined three levels on which the similarity between two entities (concepts or instances) can be measured: data layer, ontology layer, and context layer, that cope with the data representation, ontological meaning and the usage of these entities, respectively. In addition, in each of the layers corresponding background information is used in order to define the similarity more precisely. The framework is complete in the sense of covering the similarity between all elements defined in the abstract ontology model by comprising similarity measures for all above-named layers as well as relations between them. Moreover, we have validated our framework with several practical case studies in order to prove benefits of applying our approach compared to traditional similarity measures. One of these case studies is described in detail within the paper.