Recent years have seen a rapid growth of smartphone and tablet applications. Many of these applications make use of the localization capabilities of these devices in what are called Location Based Services. To be able to provide this kind of services, a reliable and real time identification of the user location is needed. Traditionally, global localization has been carried out through GPS, which provides accurate localization when working outdoors. Unfortunately, the use of GPS is affected by Non-Line-Of-Sight, making GPS localization in indoor environments not suitable. Different technologies are being used to provide indoor localization, among them, WiFi is a common choice due to its important advantages: there are WiFi access points in most buildings and measuring WiFi signal is free of charge even for private WiFi networks. Unfortunately, it also has some disadvantages: when working indoors the signal strength is strongly dependent on the building structure and some other non-desired effects appear, such as the multipath effect, signal absorption and the small scale variations. Moreover, since WiFi networks are deployed with the goal of maximizing connectivity and disregarding localization tasks, there are usually many access points distributed over the environment increasing the so-called co-channel interferences, which cause high variations in the received signal strength from the access points. The goal of this thesis is the localization of mobile devices in indoor environments using as the only available information the signal received from the already existing access points in the environment. Since WiFi is pre-installed in most of the buildings, there is no need to either modify the environment or add new devices to it. Then, the final research objective is to achieve robust WiFi real-time localization for mobile devices, available to be deployed in any environment and to be used by any device. To achieve this objective, a hierarchical fuzzy-based approach is proposed to perform localization in topologically described environments. This new approach is able to deal with multi-floor large environments that have been previously neglected in the literature. To do so, the system creates a hierarchical partition of the environment using similarity clues in a K-Means-based approach. Then, the localization system is trained using different supervised learning algorithms to classify the new WiFi samples through the hierarchical tree of the environment partition. Finally, a Bayesian filter to track the position of a device in motion has been designed. This approach was tested in a multi-floor real environment, obtaining an overall mean error distance under 3 metres.