Allianz SE struck a deal with Goldman Sachs to help the German company hedge part of its stake in China Pacific Insurance Group (CPIC) and lock in profits from two rounds of investments that Allianz made in China's third-largest insurer.

Under the deal, Allianz agreed to a future sale of 147.7 million Hong Kong-traded shares of CPIC at HK$36.77 each to Goldman in a $700 million transaction.

Allianz said the sale would leave it with a 1 percent stake in CPIC, which it called its "preferred partner in China."

Allianz's stake in CPIC means it can locking in profits from an investment in 2009 and another stake purchase in 2011. CPIC shares are up 31.3 percent from when Allianz made its first investment and up 18 percent from the time of the second deal.

Goldman declined to comment on the transaction.

The deal is similar to a hedge Goldman entered in 2011 with American Express Inc under which American Express effectively set up a short position in Industrial and Commercial Bank of China Ltd to offset part of its long-term investment in the Chinese bank.

Allianz, Europe's largest insurer, first bought into CPIC in December 2009, when it was a cornerstone investor in the Chinese company's Hong Kong listing with a $150 million purchase.

Allianz increased its stake further in January 2011, buying $855 million worth of shares from private equity firm Carlyle Group.

Allianz currently owns 243.2 million CPIC shares, according to Hong Kong stock exchange data.

CPIC's stock is up 51 percent over the past year, but it has undergone wild swings since the beginning of 2015. At one point, CPIC's shares rose more than 17 percent over five days, only to go down 11 percent in the following five days.

Allianz will continue to own a 22.95 percent stake in a health insurance joint venture with CPIC that was unveiled in December 2014.