The moves are part of a deal with Harry Wilson, a former member of the government task force that restructured GM coming out of its 2009 bankruptcy.
Wilson, who represents four hedge funds that own about 2% of the company, had previously accused GM of hoarding cash to the detriment of shareholders and had sought an $8-billion buyback and a board seat.
But on Monday he said he was impressed at how quickly GM's management responded, adding that the company agreed to just about everything the funds wanted.
"We basically said thank you," Wilson said.
GM had $25.2 billion in cash at the end of last year, part of what it called a "fortress balance sheet" designed to withstand another financial crisis. Going forward the automaker plans to maintain a cash balance of $20 billion and aims to keep its investment-grade credit rating.
The share repurchase will begin immediately and finish before the end of 2016. Investors liked the announcement. GM shares rose $1.12, or 3.1%, to $37.66.
Talks with Wilson's group had been going on for about two weeks, GM CEO
She indicated that the buyback might have come without Wilson's prodding. "We were on a path to do this anyway," Barra said.
GM recently announced plans to boost its quarterly dividend by 20% to 36 cents. Combined, the dividend increase and the buyback will cost GM $10 billion by the end of 2016.
Chief Financial Officer Chuck Stevens said a $20-billion cash reserve is enough for GM to withstand any potential economic downturn, as well as the costs of an ignition switch recall.