Position-based routing is considered to be a very promising routing strategy for communication within vehicular ad hoc networks (VANETs), due to the fact that vehicular nodes can obtain position information from onboard global positioning system receivers and acquire global road layout information from an onboard digital map. Position-based routing protocols, which are based mostly on greedy forwarding, are well-suited to the highly dynamic and rapid-changing network topology of VANETs. In this paper, we outline the background and the latest development in VANETs and survey the state-of-the-art routing protocols previously used in VANETs. We present the pros and cons for each routing protocol, and make a detailed comparison. We also discuss open issues, challenges and future research directions. It is observed that a hybrid routing protocol is the best choice for VANETs in both urban and highway environments.