The deal comes just three months after the middleware vendor turned down an earlier offer of $6.7 billion.
Oracle hopes that acquiring middleware vendor BEA will allow it to improve its own middleware suite, Fusion.
That middleware is key to helping customers migrate their systems to a services-oriented architecture (SOA), CEO Larry Ellison said in a conference call last month to discuss the company's earnings.
With Fusion already able to link to BEA's WebLogic Java application server, the deal is likely to speed Oracle's adoption of Java-based middleware, the company said.
Oracle's customers have been telling it for years to buy BEA, it said.
However the members of BEA's board were less sold on the idea: They turned down an offer from Oracle of $17 per BEA share in October, saying it "significantly undervalues BEA." Oracle in turn dismissed the BEA board's counter-offer of $21 per share as "impossibly high".
But on Wednesday the companies split the difference, and BEA's board announced it had unanimously approved Oracle's latest offer of $19.375 in cash per BEA share.
The board accepted only after spending several months looking for other ways to maximize shareholder value, BEA's chairman and CEO Alfred Chuang said in a statement.
The companies expect to close the deal by mid-year, subject to the approval of regulators and BEA shareholders.