Oracle Corp said on Monday it will buy Sun Microsystems Inc for $9.50 a share, valuing the high-end computer server maker at more than $7 billion.

The surprise announcement from the two companies comes after deal talks between IBM and Sun fell apart earlier this month, and sources with knowledge of the matter had said Sun had turned down IBM's offer to pay up to $9.40 a share.

Sun shares jumped 37.5 percent to $9.20 in premarket trading, while Oracle shares fell 4.5 percent to $18.34.

The price of $9.50 a share values Sun at about $7.1 billion based on about 745 million shares outstanding, according to Sun's latest regulatory filings.

The companies said in a statement the transaction is valued at about $7.4 billion, or $5.6 billion net of cash and debt.

(Reporting by Tiffany Wu; Editing by Derek Caney)