Dynamic nature of mobile ad hoc networks combined with their lack of centralized infrastructure make security problem the most challenging issue in such networks. The main contribution of this paper is to propose a secure and efficient key management algorithm, able to satisfying the requirement of such networks and facing their specific characteristics. The proposed algorithm is a fully distributed ID-based system which is built based on elliptic curve cryptography. The main advantage of the proposed algorithm, that gives it the superiority in its field of research, is the improvement of the performance and the security strength together. The proposed algorithm is implemented with much lower communication and computation overhead in comparison with its literature works. It is also able to update the keys while it solves the key escrowing problem. It is analyzed analytically and compared with several recently proposed key management algorithms. The analysis shows the superiority of the proposed algorithm in comparison with others. Furthermore, NS2 simulator is used to do exhaustive simulations. Simulation scenarios are done for large scale networks, to evaluate the performance of the proposed algorithm and also validate the analytical results. Results show that our algorithm could provide confidentiality, integrity, authentication and non-repudiation with order of magnitude less computation and communication overhead in comparison with former works. (C) 2016 Elsevier B.V. All rights reserved.