American Express Co., which backed out of a $1 billion bid for Alleghany Corp. five weeks ago, today announced that it had bought the Alleghany division it most cherished, Investors Diversified Services Inc., for about $773 million.

"The thing that changed is the price," said Louis V. Gerstner Jr., chairman of the American Express executive committee. "We've always been very strong on IDS and how it would fit with American Express."

Through a sales force of about 4,500 agents, IDS is a major marketer of insurance and mutual funds. The Minneapolis firm manages $16.6 billion in assets.

American Express officials say the purchase is a way to bring the financial services concern into a middle market that neither its Shearson brokerage arm nor its travel and entertainment card operation generally serves.

"Today's transaction underscores American Express's commitment to penetrating the affluent, middle market--a market we feel provides an additional important opportunity for the financial services industry," said company Chairman and Chief Executive Officer James D. Robinson III.

The stunning reversal on the American Express--IDS union is likely to be greeted more favorably by Wall Street analysts than the original deal.

Many analysts suggested when the original transaction was announced in July that American Express might be paying far more than it should for the company.

The original deal to acquire all of Alleghany was a stock purchase involving 22.875 million American Express shares then worth $1.01 billion. The agreement to buy only IDS calls for American Express to pay $337.7 million in cash plus 11.5 million shares of American Express stock, valued today at $435.5 million.

The restructured purchase does not involve Alleghany's MSL Industries, a steel products and motors company based in Lincolnwood, Ill. Gerstner pointed out that under the accounting and tax treatment proposed in the first American Express bid, it could not have sold the steel company for at least two years. "While we're sure it's a very fine steel company, it's not a business we want to be in," Gerstner said.

Some industry skeptics had also raised questions about the attractiveness of the principal IDS business--personal sales of financial products, while privately some American Express officials reportedly were disappointed with IDS's limited technology.

But the company's leadership maintains that IDS is perfectly suited to American Express' continuing expansion of its financial services operations, and Robinson said the company is "delighted" to have IDS under its wing.

The deal leaves Alleghany with only one major asset--its steel company. But F. M. Kirby, Alleghany's chairman, said the deal would "greatly accelerate" the company's evolutionary progress."