Porsche Cars North America, via PR Newswire

LONDON — Volkswagen has agreed to take full control of Porsche by buying the 50.1 percent stake it does not already own in a deal that ends a three-year negotiation between the two rival German automakers.

Under the terms of the deal, Volkswagen, whose brands include Audi, Bentley and Skoda, will pay 4.46 billion euros ($5.58 billion) in cash, plus one ordinary share in Volkswagen.

The automakers had been in discussions since 2009, when Volkswagen bought a minority stake in Porsche after the sports car maker made a failed attempt to acquire Volkswagen, a much larger company, in 2008. The botched takeover left Porsche with around 10 billion euros of debt.

Related Links The news release

Last year, the companies said they had not been able to reach an agreement to finalize a takeover because of a potential 1 billion euro tax charge from German authorities if Volkswagen exercised its rights to purchase the remaining stake in Porsche before 2014.

To avoid the tax bill, Volkswagen will now take control of Porsche’s automaking operations, while leaving Porsche SE, a holding company controlled by the Piëch-Porsche family, as a separate entity.

Porsche SE, which still owns 50.7 percent of Volkswagen’s common stock, said it would use the proceeds of the sale to pay down 2 billion euros of outstanding debt.

‘‘The unique Porsche brand will now become an integral part of the Volkswagen Group,’’ the company’s chairman, Martin Winterkorn, said in a statement. ‘‘That is good for Volkswagen, good for Porsche and good for Germany as an industrial location.”

The deal values Volkswagen’s existing 49.9 percent stake in Porsche at 3.88 billion euros, according to a company statement.

Shares in Volkswagen rose 5.95 percent in late morning trading in Frankfurt on Thursday.

Volkswagen said the takeover would drain around 7 billion euros from its cash reserves after taking on Porsche’s financial liabilities. It said it was looking to extract 320 million euros of cost savings from the takeover.

The deal is expected to close by the beginning of August.