Locomotion mode recognition plays an important role in the control of lower-limb exoskeletons and prostheses. In such applications, the accurate and timely classification of the locomotion mode, using the minimum number of sensors, is still a challenge. In this paper we present an algorithm to recognize four different locomotion modes (namely stand, walk, stair ascent, and stair descent) and all the possible transitions among them, based on wearable sensors. The algorithm grounds on an event-based and mode-dependent strategy, which is able to recognize the locomotion mode during the swing phase. Tests conducted with three healthy subjects showed an average recognition accuracy of 98.8 ± 0.4% in steady locomotion conditions. Transitions between different modes were also accurately detected during the swing phase. Further studies will be conducted to validate the algorithm and test it in real-time applications with wearable robots.