In a near unanimous vote, the European Parliament has rejected the controversial Software Patents Directive.
Rejection means that companies and software developers can continue to register patents, but protection will not be guaranteed across the EU.
"This represents a clear victory for open source," said Simon Phipps, chief open source officer at Sun Microsystems. "It expresses Parliament's clear desire to provide a balanced competitive market for software."
Dr John Collins, a partner at US law firm Marks and Clark, said: "The directive was intended to harmonise the differing interpretations of patent law concerning software inventions, but those opposed to it lobbied so intensely that it had so many amendments that rejection was the only alternative.
"The rejection means there remains no formal harmonisation across the European Union on patent law.
"The open source lobby will try to claim victory and say that this vote is a defeat for software patents, yet software will continue to be patented in Europe as it has for the past 30 years."
The directive had been hotly debated for over a year with big tech vendors such as Nokia and Siemens in support.
But it was strongly opposed by smaller developers and the likes of Red Hat, Oracle, Fujitsu, Yahoo and Sun, which had claimed that approving the directive "would be a disaster for small developers, and result in the 'Americanisation' of the European patent system".
Small tech firms generally want a patent to cover only the invention running a program, which then allows others to use the software.
Most experts see it as a delicate balance between providing legal protection to software innovators, while not setting up barriers that stifle new development.
The directive is formally known as the Computer-implemented Inventions Directive.
Latest Tesla news: Tesla stock price tanks amid reports of 'widening probe' by SEC and claims the base Model 3 loses money
SEC 'probe' takes its toll on Tesla as new research suggests that Tesla loses $6,000 on every $35,000 Model 3
10nm Cannon Lake Core i3-8121U CPUs make a rare outing with Intel's NUC mini PC
'Notorious' Australian child hacker thought he had executed 'flawless' hack
The former employee says that Tesla fired him for bringing the accusations to management internally