Sun shares have soared on the news
Business software manufacturer Oracle has said it is to acquire computer hardware and software maker Sun Microsystems for $7.4bn (£5.1bn).
Oracle is to pay $9.50 in cash for each Sun share, it said.
Oracle said the buy "transforms the IT industry, combining best-in-class enterprise software and mission-critical computing systems".
Oracle shares were down 5.56% and Sun's were up 27% in trading before the open of the New York Stock Exchange.
The offer of $9.50 per share represents a 42% premium over Sun's closing stock price on Friday.
The deal comes a month after IBM abandoned its bid to buy Sun.
"Oracle and Sun have been industry pioneers and close partners for more than 20 years," said Sun chairman Scott McNealy.
"This combination is a natural evolution of our relationship and will be an industry-defining event."
Sun said its board of directors had unanimously agreed the deal, which is expected to be completed this summer after approval from shareholders and government regulators.
Computer industry analyst Robert Jakobsen said he was initially "a little bit surprised".
"It could make sense," he added.
"The deal would strengthen Oracle's position against IBM. Oracle has done a good job on acquisitions it has done earlier."
Oracle said the takeover of Sun would boost its profits by more than $1.5bn in the first year, and by $2bn in the second.
However, Sun made a loss of $1.9bn over the past 12 months, despite sales totalling $13.3bn.
Fellow computer industry analyst Shannon Cross, said it was "a very interesting acquisition".
"It gives Oracle a very strong operating system. It gets hardware, which should be interesting to see since Oracle doesn't make things.
"It's going to give them access to customers who weren't using the Oracle database."
Although best known for its computer servers, Sun was also the developer of the Java programming language, and created the Solaris operating system.
Sun currently employs 33,000 people, while Oracle's workforce totals 86,000.
The firms have yet to comment on whether any redundancies will be made following the completion of the takeover.