Volkswagen, Europe's biggest carmaker, and luxury auto manufacturer Porsche said they had approved a plan to merge by 2011 and create an automotive giant.
Volkswagen chief executive Martin Winterkorn becomes head of both Porsche and VW after the agreement to tie up the companies, announced by the firms' supervisory boards.
The merger of the car giants draws a line under a four-year battle marked by multiple twists and turns, family feuds and boardroom battles.
"We have more than ever the means (to become) number one in the automotive industry," Winterkorn said.
It marks a clear victory for VW chairman Ferdinand Piech, nicknamed "the patriarch" by German media, and the failure of Porsche's bid to take over their far larger rivals.
Under the terms of the agreement, Volkswagen will initially buy a 42-per cent stake in Porsche by the end of 2009 for $4.7 billion, a deal that values Porsche at $17.7 billion, the companies said.
Volkswagen will then increase its capital in the first six months of 2010 by issuing new preferred shares and Porsche will increase its capital in the first half of 2011 by issuing ordinary and preferred shares.
The deal comes after months of complex and acrimonious negotiations.