General Motors is beating a retreat from one of the world's hottest car markets.

The company said Thursday it will stop selling its cars in India by the end of this year, following a "comprehensive review" of plans for the country.

Just two years ago, GM (GM) said it would pour $1 billion into its India operations. That plan has been scrapped as part of a bigger rethink of global operations.

The company is also pulling out of South Africa. It is selling its production facilities in the country to Isuzu Motors (ISUZY) and will stop selling Chevrolet vehicles by the end of 2017.

GM will continue to make cars in India for export. Vehicles made at the firm's plant near Mumbai will be exported primarily to Mexico, South America and Central America, it said.

"We explored many options, but determined the increased investment originally planned for India would not deliver the returns of other significant global opportunities," said Stefan Jacoby, president of GM International, in a statement.

Ford (F) has been exporting Indian-made SUVs to the U.S. since November 2016.

Related: GM to cut another 1,100 jobs

A second plant in the western state of Gujarat, where GM ceased manufacturing last month, will likely be sold to its Chinese partner SAIC Motor, which is bidding to enter the crowded but promising Indian market.

Nearly three million passenger vehicles were sold in India last year, according to industry data, and the country is projected to overtake Japan as the world's third largest car market by 2020.

Some of the world's top brands, including Volkswagen, Peugeot, Citroen, Toyota and Kia are all trying to cash in.

Related: China joins race for booming Indian car market

But GM has struggled to make headway over more than two decades in India, where its Chevrolet brand has captured just 1% of the market.

"Our decision in India is an important milestone in strengthening the performance of our GM International operations and establishing GM as a more focused and disciplined company," Jacoby added.

The company recently sold all of its operations in Europe to French carmaker PSA, the manufacturer of Peugeot (PUGOY) and Citroen vehicles. It has also slashed thousands of jobs in the U.S. in response to declining sales.

-- Alanna Petroff contributed to this article.