DETROIT, JULY 23 -- Ford Motor Co., the nation's second-largest auto maker, earned a record $1.5 billion in the second quarter, again surpassing industry leader General Motors Corp., whose earnings fell slightly from a year ago, the companies reported today.

Ford's earnings were up 39 percent over the second-quarter of 1986. They came to $5.81 a share on sales of $19.5 billion, compared with $1.08 billion ($4.02 a share) on sales of $17.3 billion in the second-quarter of 1986.

GM earned $980.3 million ($2.80) on sales of $26.7 billion, down from $1.02 billion ($2.92) on sales of $27.6 billion in the second quarter of 1986.

It was the most profitable quarter in Ford's history but still doesn't surpass the second-quarter record of $1.6 billion set by GM in 1984 or the industry record in any quarter of $1.61 billion, set by GM in the first quarter of 1984.

In the first half of 1987, Ford earned $2.99 billion ($11.54) on sales of $37.6 billion, up 65.5 percent from $1.8 billion ($6.72) on sales of $32.1 billion in the first half of 1986.

Ford already is close to matching its record $3.3 billion profit for all of 1986.

GM's earnings fell 14.2 percent in the first half of 1987 from a year ago.

For the first six months of 1987, GM earned $1.9 billion ($5.42) on sales of $52.8 billion, down from $2.2 billion ($6.44) on sales of $54.5 billion.

"GM is better than what many analysts had expected. The reason the results are fairly good, even though they're down from last year, is because further cost-cutting is beginning to take hold within GM," said Chris Cedergren, industry analyst with J.D. Power & Assoc. in Westlake Village, Calif.

Cedergren said GM's earnings were hurt by a decline in sales of its large, high-profit cars and by the cost of retooling three factories to build a new line of cars that will be introduced in stages beginning later this year.

GM announced today that it will lay off 2,300 workers at its Buick City plant in Flint, Mich., because of slow sales of its Oldsmobile 88s and Buick LeSabres, two large cars.

GM has been cutting production because unsold cars were piling up.

Ford, on the other hand, is selling almost everything it makes and is using the full capacity of its factories. Cedergren warned, however, that sales of the Mercury Sable, mate of the popular Ford Taurus, have begun to slow and that slowing Sable sales could spread to the higher-volume Taurus.

"If people get sick of the aero look, that could have a severe impact on Ford's profitability."

On Tuesday, Chrysler Corp., the number three auto maker, reported second-quarter earnings of $428.7 million, ($2) on sales of $6.4 billion.

Number four No. 4 American Motors Corp., which is being purchased by Chrysler, earned $30.2 million, or (17 cents) a share, on sales of $1.18 billion.

Ford sold nearly 1.7 million vehicles worldwide, up slightly from a year ago.

GM's second-quarter sales fell more than 14 percent from a year ago, to nearly 2.1 million vehicles.

Ford Chairman Donald Petersen said quarterly retail sales of Ford cars and trucks in the United States increased by more than 5 percent compared with 1986, despite an industry decline of more than 5 percent