Service discovery is a fundamental aspect of many services oriented applications; however, it cannot be directly applied to mobile ad hoc networks (MANET) due to their dynamic nature. The lack of central manager nodes results in the need of specific discovery solutions for this kind of networks. In this paper, we present a solution for the discovery of services in MANETs that is based on the classification of service's parameters according to a shared domain ontology. Our proposed discovery protocol encompasses two main processes: dissemination and search. The search process defines a pruning mechanism that enables to detect if search messages must be propagated or not, reducing the number of messages communicated through the network. The dissemination and search processes are integrated within the route management mechanism that enables to reduce the number of propagated messages. We have implemented and tested our discovery solution using the ns-2 network simulator. Experiments have been performed using rigorously constructed scenarios for testing the characteristics of the proposed solution. The obtained results show how the inclusion of the ontology not only increments the expressiveness of the search and discovery process, but also enables to reduce the number of propagated messages due to the grouping and pruning processes.