It is the social networking giant’s biggest acquisition to date.
WhatsApp has more than 450 million monthly users and is popular with people looking to avoid text messaging charges.
In a statement announcing the deal, Facebook founder Mark Zuckerberg described WhatsApp’s services as “incredibly valuable”.
WhatsApp allows users to send messages over internet connections, avoiding text messaging fees. The company claims it is currently registering one million new users a day.
It makes money by charging users a subscription fee of $1 per year, although it offers a free model as well.
Mike Butcher, techcrunch.com, explains why Facebook would want to buy WhatsApp
Silicon Valley’s newest billionaires
The deal to buy it includes $4bn in cash and approximately $12bn-worth of Facebook shares, plus an additional $3bn in stock to WhatsApp’s founders and employees at a later date.
On a conference call to discuss the deal, WhatsApp co-founder Jan Koum said he planned to operate the firm “independently and autonomously”. He will also become a member of Facebook’s board of directors.
“We’re excited and honoured to partner with Mark and Facebook as we continue to bring our product to more people around the world,” Mr Koum said in a statement.
Mr Zuckerberg said the prospect of a deal was first floated just 11 days ago.
The Facebook founder said he believed WhatsApp was on track to have a billion users, but insisted he had no plans to place advertising on WhatsApp’s interface, saying he did not think ads were the best way to make money from messaging systems.
Once the deal is finalised, Mr Koum and co-founder Brian Acton are set to become Silicon Valley’s newest billionaires.
WhatsApp has about 50 employees in total.
Cathy Boyle, a senior analyst at research firm eMarketer, said WhatsApp was valuable to Facebook for several reasons beyond advertising, including its younger user base and its popularity overseas.
“WhatsApp actually has greater penetration in a lot of international markets than Facebook,” Ms Boyle told the BBC.
She added that it was notable that Facebook’s chief financial officer David Ebersman referred to the telecommunications industry when discussing the firm’s purchase.
“WhatsApp is trying to siphon the billions that the telecom industry would make from [traditional SMS text messaging]” she said.
Ben Bajarin, from California-based technology consultants Creative Strategies, told BBC Radio 4’s Today programme that the deal would allow Facebook to tap into a rapidly growing market.
“WhatsApp is on a path towards a billion users,” he said. “They’re growing exponentially – much, much faster than Facebook.
“For Facebook this is a key growth area where, even if they don’t monetise this product, this is a way that Facebook can get the next billion smartphone consumers into their ecosystem… to touch them and engage with them in other ways than just the Facebook platform.”
Shares in Facebook dropped 5% in after hours trading before recovering slightly.
Prior to this acquisition, Facebook’s biggest purchase had been Instagram for $1bn in 2012.
It had also reportedly offered $3bn to acquire photo messaging service Snapchat.