The Internet of Things (IoT) is a key technology to interconnect the real and digital worlds, enabling the development of smart cities and services. The timely collection of data is essential for IoT services. In scenarios such as agriculture, industry, transportation, public safety, and health, wireless sensor networks (WSNs) play a fundamental role in fulfilling this task. However, WSNs are commonly deployed in sensitive and remote environments, thus facing the challenge of jamming attacks. Therefore, these networks need to have the ability to detect such attacks and adopt countermeasures to guarantee connectivity and operation. In this work, we propose a novel clustering-based self-healing strategy to overcome jamming attacks, in which we denominate fairness cooperation with power allocation (FCPA). The proposed strategy, aware of the presence of the jammer, clusters the network and designates a cluster head that acts as a sink node to collect information from its cluster. Then, the most convenient routes to overcome the jamming are identified and the transmit power is adjusted to the minimum value required to guarantee the reliability of each link. Finally, through the weighted use of the relays, the lifetime of each subnetwork is extended. To show the impact of each capability of FCPA, we compare it with multiple benchmarks that only partially possess these capabilities. In the proposal evaluation, we consider a WSN composed of 64 static nodes distributed in a square area. Meanwhile, to assess the impact of the jamming attack, we consider seven different locations of the attacker. All experiments started with each node’s battery full and stopped after one of these batteries was depleted. In these scenarios, FCPA outperforms all other strategies by more than 50% of the information transmitted, due to the efficient use of relay power, through the weighted balance of cooperative routes. On average, FCPA permits 967,961 kb of information transmitted and 63% of residual energy, as energy efficiency, from all the analyzed scenarios. Additionally, the proposed clustering-based self-healing strategy adapts to the change of jammer location, outperforming the rest of the strategies in terms of information transmitted and energy efficiency in all evaluated scenarios.