The context of the work presented in this thesis is mobile computing and knowledge management. We focus on the usage of semantic technologies for representation, sharing, and integration of knowledge about services (specially Location-Based Services) as well as agents to discover devices which can provide interesting information for users. Therefore, our main contribution is a general and flexible agent-based architecture based on the use of semantic technologies to provide services to mobile users. Location-Based Services (LBS) provide added value by customizing the information offered to mobile users based on their locations. Current LBS are usually designed for specific scenarios and goals with predefined schemas for the modeling of the elements involved in their scenarios. Apart from specific LBS, some approaches of architectures to provide users with LBS have been presented before. However, these approaches assume either a centralized architecture or its distribution using a fixed infrastructure. In addition, these approaches usually act as mere repositories of services and do not deal with their execution to obtain the information that the user needs. Our proposal is the system SHERLOCK (System for Heterogeneous mobilE Requests by Leveraging Ontological and Contextual Knowledge) that offers a general and flexible architecture to provide users with LBS which might be interesting regarding their context. SHERLOCK is based on semantic and agent technologies: 1) ontologies are used to model the information about users, devices, services, and the world around a device whereas a semantic reasoner is used to manage these ontologies and infer non-explicit knowledge; and 2) an agent-oriented architecture enables SHERLOCK devices to autonomously exchange knowledge keeping their local ontologies updated, and to process user information requests, finding what the user needs wherever it is. The use of these two technologies helps SHERLOCK to be flexible in terms of both the services it offers to the user (which are learned from the interaction between devices), and the mechanisms to find the information that the user wants (which adapt to the underlying communication infrastructure).