The US computer giant said on Friday copies of the source code from its Windows NT and Windows 2000 operating systems were being traded over the internet.
But Microsoft said the copies comprised a tiny portion of the millions of lines of code used to create its cash cow products.
Source code is the intellectual property and lifeblood of any software company, since it is the basic language used to create software programs.
Microsoft has only shared its source code with close partners and carefully chosen organisations, with legal agreements that threaten litigation in the event of that any of it is leaked.
"It's illegal for third parties to post Microsoft source code, and we take such activity very seriously," Microsoft spokesman Tom Pilla said.
The leak is the second big security breach recently announced by Microsoft. The company admitted on Wednesday there was a security flaw in some versions of Windows that lets hackers access millions of computers using the system worldwide.
The code leak appears to come from an unidentified software developer with access to Microsoft's code. Software companies that create programs running on Windows need access to source code to build their own products.
One main risk in having source code exposed to the public is the possibility that hackers could break into computers running Windows NT or Windows 2000 and destroy or steal data.
Although the company said that was unlikely, given the relatively small portion of code that had been circulating, a greater risk could come from others using the code as a base for developing software that competes with Windows.
Microsoft is the world's biggest software company. More than nine out of 10 personal computers, runs on its software.
Microsoft said that it was working with the Federal Bureau of Investigation and legal authorities to try and track the origin of the source code leak.