LOS ANGELES – General Motors Co. is getting back into subprime lending, a move that will give its dealers more options to lease and finance car sales but one which critics worry could drive the automaker into another financial pileup.

GM said Thursday that it would buy AmeriCredit Corp. in an all-cash transaction valued at about $3.5 billion, or $24.50 a share.

The acquisition gives GM what’s known as a “captive finance unit” or lending division that allows it more flexibility to offer lease and finance deals. It would fill the role once played by GMAC; the automaker sold all but a minority interest in that company in 2006.

“Adding AmeriCredit to our team will improve our competitiveness in auto financing offerings, and I am very pleased to have them on board,” GM Chief Executive Edward E. Whitacre Jr. said.

But the deal immediately drew fire from critics, who recalled how the Detroit automaker’s former addiction to providing easy credit and cut-rate financing contributed to GM’s financial woes and eventually a federal bailout that cost taxpayers billions of dollars.