Prime Minister James Callaghan is engaged in an extraordinary battle here with his Labor Party government's traditional allies, Britain's trade unions.

Callaghan, one of the few cabinet members from a working class background, is fighting to preserve the government's successful campaign against runaway inflation by limiting wage gains this year to 5 percent.

The course of the struggle here, much like pay contests in other northern European democracies, is likely to be watched closely by the Carter administration which may soon announce wage guidelines.

Callaghan's firmness has already touched off a nationwide strike of 57,000 workers at Ford Motor Co.'s 23 plants here. It began a full four weeks before the contract ran out. The Ford unions say they will not even bargain with the company unless it drops its insistence that it must obey the government's 5 percent rule. Ford, in turn, complains that it is caught in the middle, fearful it will lose up to $400 million in government orders, investment and subsidy if it breaches Callaghan's limit.

Yesterday at Blackpool, Callaghan's own Labor Party rejected any pay restraint by what appeared to be an overwhelming 2-1 vote. But the defeat at the annual conference is more apparent than real.

Under the party's rules, each union casts a bloc vote for its entire membership. Of the 4,017,000 votes against the government, no less than 2,086,000 came from just two men. They are the leaders of the Transport and General Workers Union and the Amalgamated Union of Engineering Workers, the two unions striking at Ford.

The vote was a setback for Callaghan, but it is less than fatal. In private, some union leaders acknowledge that free collective bargaining is a thing of the past and that some form of wage policy is essential.

Despite his opposition, Callaghan shows no sign of yielding. The memory of a spiraling 30 percent price-wage inflation three years ago is still strong here. The government is convinced that wage restraint is the only way to prevent a recurrence.

An outsider might be tempted to think that trade union hostility will be deadly for Callaghan when he next faces the voters, probably in the spring. But if he succeeds, if he keeps inflation where it is now, below 10 percent, he is likely to earn the gratitude and votes of large numbers of middle class citizens.

The unions - for all their demands for "free" bargaining and complaints of Callaghan's "rigidity" - really have no other place to go. They are not putting their money where their mouth is. The two big unions at Ford, for example, have just contributed $584,000 to the Labor Party's war chest, big money for the labor movement here.

Callaghan, a former trade union official himself, will not have an easy time with his pay policy. The first two years it was tried it worked with the open assent of the union movement. This past year, there was again a large measure of restraint because the unions tacitly accepted the policy.

But now, even though some leaders would like to continue it, pressure from the rank and file is so strong that the unions have had to condemn any curb on pay.

The calendar put Ford's agreement first on the firing line and it is a good target for the union. The British company doubled its profits to [WORD ILLEGIBLE] million last year. Its chairman, Dr Terence Beckett, gave himself an 80 percent raise to $109,000. That it not much by U.S. corporate standards but is very big money here.

The base pay of Ford workers is $140 a week. When the company offered to raise this 5 percent, about [WORD ILLEGIBLE] workers walked out even before their shop steward could assemble them. They have been out since Sept. 21.

The unions are asking for a huge increase in pay and a big cut in hours that would lift hourly costs by 42 percent. On top of that, they want bigger pensions and other fringes. Ford says the package would raise costs by [WORD ILLEGIBLE] percent and that may not be much of an exaggeration. The two unions have quite clearly decided to try to smash the 5 percent curb with Ford as the test case.

The Callaghan policy is not quite as rigid as it sounds. The government would approve any increase above 5 percent that can be matched by an offsetting increase in productivity.

There is plenty of room for productivity gains at Ford. Ten British workers produce what four West German and five Belgain Ford workers turn out with the same equipment. So Ford has offered productivity increases to match or exceed the pay gains, an offer that tempts some but act the majority in the plants.

To stiffen Ford's backbone, the government threatens to stop buying 25,000 Ford vehicles, worth about $200 million, and reduce other government aids worth an equal other government aids worth an equal amount. Beckett says he is the victim of a political, not an industrial dispute, but the government would retort that the line between politics and economics was long ago breached by big unions and big corporations.

Britain could suffer a Ford strike with little pain. But coal miners, garbage collectors, power workers and waterworks employes are all eager to jump over 5 percent.

Callaghan showed his muscle last year when he defeated an equally perilous strike of firemen by using troops. Whether Callaghan can use this last-resort weapon again, whether public opinion will remain with him and how far productivity deals can be strained to accommodate more than 5 percent are all vital questions that the coming weeks will answer.