In a tie-up that came as a surprise to both Wall Street and the technology community, Oracle announced it was paying $9.50 a share for Sun, valuing the company at $5.6bn once its outstanding cash and debt are factored out.
Sun had previously been in talks to sell itself to IBM, which was initially willing to pay a higher price of between $10 and $11 a share. But talks broke down two weeks ago as IBM reduced its valuation, and amid potential delays in getting clearance from the competition authorities.
Sun's chairman, Scott McNealy, said the combination with Oracle marked a "momentous day" in the technology world: "There is no question in my mind that this transaction redefines the industry."
McNealy said that Sun and Oracle, having been "pioneers and partners for way longer than I like to think about"‚ were "coming together for the next phase of computing". Sun's stock rocketed by 36% to $9.16 during early trading on the technology-dominated Nasdaq exchange.
A pioneer in network computing, Sun was valued at more than $200bn during the dotcom boom of the late 1990s. But orders for its servers and storage computers have been slowing and it has made losses in three of the past four quarters.
Oracle sees the company as a logical fit because Sun's Java and Solaris software is already used in its own fleet of databases and in its middleware software, which joins diffuse applications. Oracle's chief executive, Larry Ellison, said Java was one of the industry's best-known brands, used on hundreds of millions of computers, mobile phones and even DVD players.
Ellison said the combined company would deliver complete systems "from database to desk" to its 320,000 global customers: "With the acquisition of Sun, Oracle will be able to make all the pieces of the technology stack fit together."
Analysts have suggested for some time that Sun's prospects were fading and that it needed a buyer. Before the negotiations with IBM, there had been speculation that hardware manufacturers Hewlett-Packard or Dell could be interested.
Ray Wang, an industry expert at Forrester Research in California, said that although Java and Solaris appeared the "crown jewels" of the deal, there were other benefits: "Oracle also gains an innovation engine with the assets of Sun's Labs group, which pioneers a series of innovations that include potential enterprise solutions for the virtual world."
With a global workforce of 30,000, Sun employs 2,000 people in Britain and Ireland. The company has a regional head office in Camberley, Surrey, and a manufacturing arm in Linlithgow, West Lothian. The company announced in December that it was shutting its plant in Scotland, with a loss of 130 jobs.