Facebook has entered into an agreement to acquire WhatsApp, the popular messaging app, for $19 billion in cash and stock, according to a filing Wednesday.

The deal is by far Facebook's largest acquisition to date and comes after rumors in late 2012 and early 2013 that Facebook and Google were vying to buy the messaging service.

According to the filing, Facebook has agreed to pay $12 billion in stock and $4 billion in cash for the company. Facebook has also agreed to pay an additional $3 billion in restricted stock units to WhatsApp's founders and employees as part of the deal, which would bring the total deal price to about $19 billion.

WhatsApp, founded in 2009 by former Yahoo engineers Jan Koum and Brian Acton, is the most popular of a set of mobile messaging apps that some argued posed a threat to Facebook's business. The app served as an alternative to SMS by letting users send messages for free across smartphone platforms. It currently has more than 450 million people who use the app every day.

"WhatsApp is on a path to connect 1 billion people. The services that reach that milestone are all incredibly valuable," Mark Zuckerberg, Facebook's cofounder and CEO, said in a statement. "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."

On an investor call that followed the announcement, Zuckerberg added: "The growth rate they have today and the monetization that's early but promising and in place, we see a clear trajectory ahead and are excited to work together on this."

Unlike Facebook, WhatsApp does not make money through ads. Instead, WhatsApp is free to use for the first year and then charges $0.99 a year for a subscription after that. The founders have been firm on not wanting to introduce advertising, a point that was re-iterated by Zuckerberg and Koum on the call.

"We think that for our product, advertising is not necessarily the right way to go," Koum said. "We think we have a very solid monetization system in place."

If the deal doesn't go through, Facebook will pay a breakup fee of $1 billion to WhatsApp, which is still more than the total amount Facebook ended up paying to acquire Instagram.

Facebook stock declined by more than 4.5% in after hours trading following the announcement.