PARIS—Carrefour SA said Friday it will sell its Greek supermarket to its local partner and walk away from the country at a loss, offering concrete evidence of foreign investors severing ties with Greece amid a deeply contracting economy and political upheaval.

The announcement comes just two days ahead of pivotal elections that could prove decisive in whether Greece stays in the euro zone or not. A host of international companies have said they are preparing contingency plans for such a risk, with many voicing concerns about how to retrieve cash in the event of Greece leaving the 17-nation common currency.

For Carrefour, the decision to exit Greece represents a strategic shift under new chief executive Georges Plassat, who took over from Lars Olofsson last month with a mission to turn the struggling retailer around. Mr. Plassat is due to make his first public presentation as CEO to the annual shareholders meeting on Monday.

The French retailer said it would sell its 50% stake in its supermarket chain in Greece to the Marinopoulos family and take a mostly noncash charge of €220 million ($277.9 million), comprised largely of a write-down of its investment in Greece. Carrefour didn't disclose further details, notably on the cash component of the financial charge. Carrefour had already written down its Greek business by €188 million in 2011.

A banker for the Marinopoulos family, which will now fully own Carrefour Marinopoulos, said it has agreed to pay Carrefour a symbolic euro for the stake. Jean-Marc Forneri of Paris-based investment bank Bucéphale Finance, which advised the family on the deal, said the Greek buyer will invest €300 million in the stores.