As large-scale sensor networks become more feasible, properties such as stateless nature and low maintenance overhead make postion based routing increasingly more attractive. Motivated by the fact that sensor networks would probably be deployed in a three dimensional space, we present a novel 3D geographical routing algorithm (3DGR) that makes use of the position information to route packets from sources to destinations with high path quality and reliability. The locality and high scalability of this algorithm make it suitable for wireless sensor networks. It provides high adaptability to changes in topology and recovery of link failures which increases its reliability. We also incorporate battery-aware energy efficient schemes to increase the overall lifetime of the network. To reduce latency, a method of keeping a small record of recent paths is used. We also show that location errors will still result in good performance of our algorithm while the same assumptions might yield bad performance or even complete failures in other popular geographical routing algorithms. We evaluate the 3DGR protocol using simulation. Compared to other geographic routing algorithms, we find that 3DGR exhibits noticeably longer network lifetime, smaller path stretch, smaller end-end delay and better packet delivery ratio.