The network hub nodes consumed excessive energy and failed prematurely, thus it reduced the network lifetime. In order to solve the problem, distributed lifetime optimized routing algorithm (DLOR) for wireless sensor networks was proposed. Energy for transmitting data and neighbor node residual energy were considered comprehensively. Then new weight function was introduced and distributed asynchronous Bellman-Ford algorithm was also used to construct the shortest routing tree. Finally, data were gathered along the shortest routing tree to sink node. Simulation results show that DLOR algorithm can extend network lifetime and enable cost-effective energy consumption. Under certain conditions, DLOR algorithm outperforms PEDAP, GreedyDijkstra, LET, Ratio-w and Sum-w algorithms.