Facebook spurned an offer from Microsoft's rival Google, which was also keen to invest the site.
Microsoft will also sell internet ads for Facebook outside the United States as part of the deal that took several weeks of negotiating.
Microsoft already provides banner advertising and links on the US site.
Mark Zuckerberg started the online social networking site in his Harvard University dorm room less than four years ago.
Mr Zuckerberg, 23, has indicated he would like to hold off on an initial public offering for at least two more years.
He rebuffed a $1bn takeover offer from Yahoo last year.
Facebook hopes to become an advertising magnet by substantially increasing its current audience of nearly 50 million active users.
Facebook allows users to set up personal web pages and communicate with each other.
Google and Microsoft have crossed horns before for hot Internet properties.
Google beat Microsoft with a $1.65bn acquisition of online video sharing site YouTube last year.
Facebook expects to make a profit of $30m this year so on conventional valuations a $15bn price tag would look expensive.