The mega-deal bolsters the world's biggest social network -- which has more than 1.2 billion members -- with the 450-million-strong WhatsApp, which will be operated independently with its own board.
It is Facebook's biggest acquisition and comes less than two years after Mark Zuckerberg's firm raised $16 billion in the richest tech sector public stock offering.
The purchase includes $12 billion in Facebook shares and $4 billion cash. It calls for an additional $3 billion in restricted stock units to be granted to WhatsApp founders and employees that will vest over four years.
"The acquisition supports Facebook and WhatsApp's shared mission to bring more connectivity and utility to the world by delivering core Internet services efficiently and affordably," said a Facebook statement.
Facebook reportedly sought to acquire another hot messaging firm, Snapchat, for $3 billion last year. In 2012 Facebook closed its deal for Instagram, worth some $1 billion at the time based on stock value.
"WhatsApp is on a path to connect one billion people. The services that reach that milestone are all incredibly valuable," said Zuckerberg, Facebook's founder and chief executive.
"I've known (WhatsApp founder) Jan (Koum) for a long time and I'm excited to partner with him and his team to make the world more open and connected."
WhatsApp is a cross-platform mobile app which allows users to exchange messages without having to pay telecom charges.
Koum, who joins Facebook's board under the deal, said “WhatsApp's extremely high user engagement and rapid growth are driven by the simple, powerful and instantaneous messaging capabilities we provide. We're excited and honored to partner with Mark and Facebook as we continue to bring our product to more people around the world."
In a blog post, Koum said, "Almost five years ago we started WhatsApp with a simple mission: building a cool product used globally by everybody. Nothing else mattered to us."
The tie-up gives WhatsApp "the flexibility to grow and expand, while giving me, (co-founder) Brian (Acton), and the rest of our team more time to focus on building a communications service that’s as fast, affordable and personal as possible," Koum added.
The acquisition represented likely the biggest-ever price for a tech startup, trumping the $8.5 billion paid for Skype -- which allows users to make voice and video calls over the Internet -- by Microsoft in 2011.
"The size of this deal is really massive and it will get people talking about a bubble," Greg Sterling at Opus Research told AFP.
Sterling said the deal is a risk for Facebook because "in social media you have a flavor of the month, and next year we might have another app with extremely rapid growth."
"I think (the high price tag) comes from the frustration of not being able to buy Snapchat, and then there is the youth factor," Sterling added.
"Facebook really needs to have vehicles to attract younger users, and Instagram is not going to do that by itself."
With this strategy, Sterling said Facebook "is becoming a kind of holding company for different social media properties that appeal to different groups."
Sterling said Facebook may have some ability to "monetize" WhatsApp by delivering ads over the messaging service.
Roger Kay at Endpoint Technologies said WhatsApp has become one of the most popular mobile applications worldwide "because it allows you to message anybody anywhere for free."
Kay said the deal makes sense on one level because of Facebook's record stock run-up.
"When you have a stock like that which has run up quickly and created a lot of paper value, it's good to trade that for other value," he told AFP.
"It's not obvious how they can get $12 billion out of this but it's been clear for a while that WhatsApp is very interesting. It reminds me a little bit of Skype."