Microsoft has agreed to pay AOL $1.056 billion to acquire 800 patents and gain licenses to the rest of the patents AOL will continue to own after the pending sale.

It leaked out a few weeks ago that the struggling AOL was looking to shore up its financial position by selling its patent portfolio, and Microsoft won an auction for the intellectual property. In addition to buying more than 800 patents and related patent applications outright, Microsoft will gain non-exclusive licenses to the remaining 300 or so patents AOL will keep.

AOL is also receiving a license to the same patents it's selling Microsoft, an important factor given how frequently tech companies file patent lawsuits against each other these days. Big-money patent sales are increasingly becoming a tool for tech companies to either ward off lawsuits or launch a few of their own. Google, under fire over Android, recently bought patents from IBM, and is buying Motorola Mobility largely because of the company's patent portfolio. Facebook, upon being sued by Yahoo, went out and acquired new patents and then used them to countersue Yahoo.

Microsoft's patent portfolio is already among the strongest in the industry, even before today's announcement. A recent analysis by Envision IP of 700 of the AOL patents to be acquired by Microsoft showed that 140 relate to online communications, primarily instant messaging and e-mail technology. Another 81 patents owned by AOL relate to browser technologies and user interfaces, 77 relate to search engine technologies, 74 relate to multimedia, 58 relate to network hardware and routing, 52 relate to network security, 41 relate to voice communication, and 29 could be applied to social networking systems.

The Microsoft/AOL sale, if it meets regulatory approval, is expected to be completed by the end of 2012. AOL said the 300 patents and patent applications it will keep after the sale cover technologies related to "advertising, search, content generation/management, social networking, mapping, multimedia/streaming, and security."

UPDATE: AllThingsD just reported that another component of this sale involving transfer of stock in an unspecified "AOL subsidiary" just happens to be the AOL-owned Netscape. "Microsoft will buy the underlying patents for the old browser, but AOL will hang onto the brand, and the related Netscape businesses," the report states.