Canadian food processor Maple Leaf Foods agreed to sell its rendering and biodiesel business to Darling International Inc (DAR) for about C$645 million ($613.6 million) in cash, causing shares in both companies to spike on Friday.

Maple Leaf, the maker of Dempster's Bread and Klik luncheon meat, has been hit hard by low margins for hog production due to high prices of corn and wheat. It reported a surprising second-quarter loss on July 31.

The sale to Texas food waste recycling company Darling allows Maple Leaf to focus on boosting profits in selling packaged foods to consumers and effectively deploying capital, Chief Executive Officer Michael McCain said in a statement on Friday.

Darling CEO Randall Stuewe said the deal made the company North America's leading provider of rendering and recycling services.

Rothsay, Maple Leaf's rendering and biodiesel business, operates six rendering plants in Manitoba, Ontario, Quebec and Nova Scotia and a biodiesel facility in Quebec.

Maple Leaf shares rose as much as 9.9 percent to C$14.72 in early trading in Toronto, while Darling jumped as much as 14.5 percent to $22.13 in New York.

The sale has pros and cons for Maple Leaf investors, said analyst Robert Gibson of Octagon Capital.

"(It's) bad in that Rothsay was a hugely profitable business, and they're going to lose those earnings," Gibson said. "But it significantly improves the balance sheet."

Maple Leaf said it would use initial proceeds from the sale to pay down debt.

Shares of Maple Leaf soared in June and July after news that U.S. rival Smithfield Foods had inquired about buying it, stoking ideas that the company may be a takeover target. Instead, China's Shuanghui International Holdings agreed to buy Smithfield for $4.7 billion, and Maple Leaf stock has fallen off its mid-summer highs.

Rothsay renders restaurant grease and animal byproducts from its meat-packing operations into animal feed, edible lard, biodiesel and cosmetics, among other products.

The companies expect the sale to close by the end of 2013, subject to approval by Canada's Competition Bureau.

Maple Leaf is carrying out a C$560 million multiyear program to upgrade its meat operations as it seeks to boost profits and better compete with U.S. rivals.

BMO Capital Markets Corp was the financial advisor to Darling, and K&L Gates and Bennett Jones was legal counsel. J.P. Morgan Securities LLC will lead Darling's debt financing.

($1 = 1.0512 Canadian dollars)

(Additional reporting by Bhaswati Mukhopadhyay in Bangalore; Editing by Savio D'Souza)