Detroit-based lender Ally Financial said it is planning to partly repay a US bailout as it looks to move out of federal control by boosting its capital through a share sale.

Ally decided to sell about $1bn (£638m, €747m) of common stock to investors and pay about $5.9bn to the taxpayers as a part of its plan to purchase the preferred shares held by the US Treasury. It is planning to sell 166,667 common shares of the company to a group of investors.

The company will pay over $5.2bn to repurchase the outstanding preferred securities. Furthermore, it will pay $725m to end the Treasury's right to get the extra payments if any of the company's shares are sold below a particular price.

The special Treasury right is part of an agreement reached in 2010, whereby the company's preferred shares were converted into common shares.

Ally has to repay the $17.2bn government bailout it received during the 2008 financial crisis. The company has so far repaid about $6.2bn to the Treasury and the current transaction will take the figure to $12.1bn.

The company has been exploring a number ways to repay the loans, including asset sale and an initial public offering.

"The actions announced today will clear the way for Ally to pursue the next steps to ultimately exit" the government bailout, chief executive officer Michael Carpenter said in the statement. He also added that the deal will reduce the regulatory scrutiny on the business.

Ally, the former auto-lending arm of General Motors, earlier put its troubled home-loan subsidiary Residential Capital into bankruptcy after a series of mortgages went bad.

Despite the regulators applying "a substantially higher bar to Ally than to any other bank", the company made substantial progress in repaying its debt and reorganising its operations. That was after the US Federal Reserve declared the company in March as one of the worst top 18 banks with poor capital.

"Ally has made great progress in restructuring and strengthening its business in order to repay the taxpayer, and we look forward to continuing to work with the company to recover the remaining investment," Assistant Treasury Secretary for Financial Stability Tim Massad said in a statement.

The company generated over $40bn of retail deposits, besides raising about $7.7bn by selling off its international businesses.

With the current deal, the company will slash the Treasury's ownership stake to 65% from around 74%.