Activist investor Carl Icahn withdrew his offer to buy the remaining shares of petroleum company CVR Energy Inc. (CVI), ending his bid to take the company private, according to a Securities and Exchange Commission filing.

Shares sank 2% after hours to $28.95, though the stock as of Tuesday's close was up 58% so far this year.

Mr. Icahn had offered to pay from about $29 to $30 per remaining share, but, in a letter to the company's board, said he was pulling the offer since "a number of market conditions have changed," including significantly widening of crack spreads.

Mr. Icahn earlier this year bought an 80% stake of the Sugarland, Texas, company at $30 a share with plans to immediately resell the entire business for at least $35 a share. Despite hefty refining margins at the company's Midwestern plants in the past few quarters, analysts predicted that the price tag would attract few buyers.

The company, which operates refineries in Oklahoma and Kansas, recently failed to identify an acquirer and said Mr. Icahn no longer intended to sell the company.

This month, CVR said its second-quarter profit rose 24%, as the company's revenue increased more than expected.

Write to Ben Fox Rubin at ben.rubin@dowjones.com

Subscribe to WSJ: http://online.wsj.com?mod=djnwires