A majority of General Motors bondholders have agreed to a debt-for-equity exchange, a source familiar with the voting said on Sunday, helping pave the way for a bankruptcy filing expected on Monday.

The bondholders completed voting on Saturday and slightly more that 50 percent agreed to the swap that would give them up to 25 percent ownership of a reorganized GM in exchange for $27 billion in debt, said the source.

A bankruptcy filing by GM would rank as the third-largest bankruptcy in U.S. history and the largest and most complex manufacturing bankruptcy ever.

GM has been losing market share since the early 1980s when it commanded 45 percent of the U.S. market. It has been hurt by its reliance on a truck-dominated vehicle line-up and by a deep plunge in demand as credit tightened in 2008.

Since last week, GM has been racing to complete a series of last-minute deals intended to help speed its way through a fast-track bankruptcy that would see it emerge under the majority ownership of the U.S. government.

Those deals have included a new contract for the United Auto Workers union and an agreement to spare GM's Opel brand from collapse in a deal brokered by the German government.

Bondholders have been one of the last pieces to fall into GM's complicated bankruptcy puzzle under the direction of the autos task force appointed by the White House and headed by former investment banker Steve Rattner.

In late March, the Obama administration put the automaker on 60-day notice to restructure and clinch concessionary deals with its union and bondholders.

The U.S. government has already pumped $19.4 billion in emergency funds into the Detroit-based automaker since the start of the year.

(Reporting by John Crawley, additional reporting by Poornima Gupta and Kevin Krolicki in Detroit; Editing by Tim Dobbyn)