JOHANNESBURG — South Africa’s largest trade union withdrew its support for the African National Congress on Friday, a move that is likely to erode the party’s dominance ahead of national elections next year and reorder the politics of a country the party has governed with huge majorities since the end of white rule two decades ago.

The National Union of Metalworkers of South Africa, which calls itself “the biggest union in the history of the African continent,” with 338,000 members, announced Friday after a special congress that it would seek to start a socialist party aimed at protecting the interests of the working class. It was a direct rebuke to the A.N.C., which since its days as an underground movement resisting apartheid rule has portrayed itself as the champion of South Africa’s downtrodden.

“It is clear that the working class cannot any longer see the A.N.C. or the S.A.C.P. as its class allies in any meaningful sense,” Irvin Jim, the union’s secretary general, said at a news conference, referring to the governing party and its partner in government, the South African Communist Party.

The announcement came at the end of 10 days of mourning for Nelson Mandela, the man who led the A.N.C. to victory in the nation’s first fully democratic elections in 1994 and was to many people here the moral compass of the party. His successors, especially the current president, Jacob Zuma, have come under increasing fire for allegations of corruption and cronyism.