Facebook is buying WhatsApp, agreeing to pay $19 billion in cash and stock for the popular smartphone messaging service.

Revealed today in a filing with the Securities and Exchange Commission, the deal is Facebook's largest acquisition to date, but it's just the sort of move the company was expected to make. The social networking giant has been quietly exploring the use of WhatsApp and other messaging services popular among teens, a demographic where Facebook's influence has begun to wane. Recently, the company failed in its efforts to acquire another of these teen-centric services, SnapChat, and it has now filled the gap with WhatsApp.

On a recent earnings call, Facebook admitted that teens are spending less time on its service, and a tool like WhatsApp is a way of pushing this trend in the other direction. Facebook offers its own messaging services for smartphones – including a SnapChat clone – but WhatsApp gives it instant access to a new and relatively large group of youngsters who are actively messaging each other on a daily basis. According to Facebook, the service now spans 450 million monthly users, and about 70 percent of those are active on any given day.

>The deal is Facebook's largest acquisition to date, but it's just the sort of move the company was expected to make

According to the SEC filing, Mark Zuckerberg and company will acquire all outstanding stock and options in WhatsApp for about $4 billion in cash and 183 million Facebook shares, which are currently worth about $12 billion. The deal also includes an additional $3 billion in stock that will go to the founders and employees of WhatsApp. Jan Koum, the WhatsApp co-founder and CEO, will join the Facebook board.

"WhatsApp is on a path to connect 1 billion people. The services that reach that milestone are all incredibly valuable," read a statement from Zuckerberg. "I've known Jan for a long time and I'm excited to partner with him and his team to make the world more open and connected."

Facebook is by far the world's most popular social network, with over 1.2 billion users worldwide. But if Zuckerberg and crew are to retain their hold on the world – and continue to expand its efforts to serve ads to all those people – they must continue to evolve with the ever-changing tastes of the teenage set. For this reason, the company won't fold WhatsApp into its existing service.

As it has done with the photo-sharing site Instagram – another recent purchase – Facebook will continue to operate WhatsApp as a largely standalone service, under the existing WhatsApp name. That's what the company said in its press release, but more importantly, it's the best way to retain the young set of users the company has just paid so much for.

In many ways, WhatsApp's breed of smartphone messaging is "the killer app," something that can capture the attention of users no matter where they are or what else they're doing. And ultimately, services like this can be great place to serve ads. For Facebook, the trick is to find subtle yet effective ways of dovetailing myriad smartphone apps with its larger service, of eventually bringing teens and others into the larger fold.

It's a trick the company must learn well. Increasingly, the world is moving away from sites like Facebook.com and towards a wide range of applications loaded onto mobile phones. Clearly, Facebook recognizes that its future lies with tools like WhatsApp. Now, the task is to make it happen.