In wireless sensor networks, sensor nodes located close to the base station or sink are more susceptible to energy loss, leading to premature disconnection of the network or energy holes. This is due to the fact that all traffic is forwarded towards the sink, increasing the workloads for these closer nodes. One solution for this issue is to shorten the hop distance a sensor’s data has to travel until reaching the sink, by deploying additional relay nodes. This paper considers the problem of optimal relay node placement for maximizing the network lifetime of wireless sensor networks in three-dimensional terrains. We first design a mathematical model of the problem and reformulate it as a mixed-integer programming model to provide a basis for finding lower bound solutions. We divide the problem into two phases and show that the second phase can be solved exactly using an algorithm based on maximum flow and binary search. We then propose a local search algorithm for the first phase, utilizing the exact algorithm to create full solutions. Experimental validation on 3D datasets has been carried out to demonstrate the performance of our algorithms.