Facebook adds on prior to IPO.

Facebook has agreed to buy mobile photo-sharing app Instagram for approximately $1 billion in stock and cash. It is Facebook’s largest acquisition to date (nothing else even comes close), and comes just weeks before its highly-anticipated IPO.

According to its registration documents, Facebook had around $3.9 billion in cash on hand as of year-end 2011.

“This is an important milestone for Facebook because it’s the first time we’ve ever acquired a product and company with so many users,” said Mark Zuckerberg, in a statement posted on his Facebook timeline. “We don’t plan on doing many more of these, if any at all. But providing the best photo sharing experience is one reason why so many people love Facebook and we knew it would be worth bringing these two companies together.”

San Francisco-based Instagram had raised around $8 million in venture capital funding, from Andreessen Horowitz, Baseline Ventures, Benchmark Capital, Chris Sacca, Adam D’Angelo and Jack Dorsey.

Then, last week, it reportedly closed on $50 million in new funding at a $500 million valuation that included new investors Sequoia Capital, Thrive Capital and Greylock Partners. That’s right, a 2x ROI in just a couple weeks! And, yes, something seems a bit… ummm… off about the deal. Namely, why would Instagram accept new funding (i.e., dilution) just days before an acquisition — particularly at a valuation so much lower than what Facebook was offering?

“It’s important to be clear that Instagram is not going away,” Instagram CEO Kevin Systrom wrote on his company blog. “We’ll be working with Facebook to evolve Instagram and build the network. We’ll continue to add new features to the product and find new ways to create a better mobile photos experience.”

For context, Yahoo YHOO acquired photo-sharing company Flickr for just $35 million 2004.

Sign up for Dan’s daily email newsletter on deals and deal-makers: GetTermSheet.com