J. Lindsay Almond Jr., 87, an eloquent orator and lawyer who was governor of Virginia from 1958 to 1962 at the height of the turbulent conflict over school desegregation, died last night at St. Luke's Hospital in Richmond.

As an attorney general before becoming governor, and as a member of the powerful Byrd machine, he had won a reputation as one of the most talented legal advocates of the system of segregation that had been entrenched in his state and throughout the South.

As Virginia's chief executive, faced with court decisions unfavorable to the state's system of strict segregation in the schools, Mr. Almond helped lead the way toward abandonment of the defiant policy of "massive resistance" to integration.

While his actions outraged many of those who had viewed him as their champion, and made him one of the most controversial men to hold power in Richmond, scholars view him now as a governor who played a key transitional role in modern Virginia government and history.

Nevertheless, despite the high passions they aroused, the conflicts between him and his former supporters and associates were not fought over segregation and integration so much as they were over the best means of avoiding massive integration.

When he left office in 1962, almost eight years after the Supreme Court's historic school desegregation decision of 1954, fewer than 1 percent of Virginia's black pupils attended integrated schools.

Before becoming state attorney general, Mr. Almond served from 1946 to 1948 as a Democratic member of Congress from the 6th District. After leaving the governor's office, he continued to live in Richmond, while serving here for 10 years as a judge on the U.S. Court of Customs and Patent Appeals.

Mr. Almond had been hospitalized about six weeks ago, suffering from pneumonia.

In a statement last night, Gov. Gerald L. Baliles said Mr. Almond "served our commonwealth long and ably. With his passing, so too passes a part of Virginia history. Gov. Almond will be remembered as the loyal Virginia leader who finally said 'enough' to Massive Resistance . . . . "

A descendant of seven ancestors who fought for the Confederacy in the Civil War, Mr. Almond was born in Charlottesville, the son of a locomotive engineer. He attended the University of Virginia and in 1923, after working for a year as a high school principal to earn money, graduated from its law school. While practicing law in Roanoke in 1925 he met Harry F. Byrd, and made speeches in Byrd's gubernatorial campaign.

His support of Byrd, the dominant figure in Virginia politics for years, helped him in 1933 to appointment as a judge of the Roanoke Hustings Court, a post he held until being elected to Congress.

After leaving Washington in 1948 at Byrd's behest to become attorney general, Mr. Almond became embroiled in the growing legal controversies over school segregation.

He described himself once as recognizing that the Virginia's schools "had been separate but not equal," but also as having been "very sincerely wedded to the soundness of the separate but equal doctrine" that prevailed. He championed this doctrine in the courts, and in the suit that resulted in the 1954 Supreme Court decision, Mr. Almond argued Virginia's case.

With his name a household word among white voters, he was swept into the governor's chair in 1957, the year after the legislature passed the so-called Massive Resistance laws to close any public school the federal courts ordered integrated.

But in 1959, when the state Supreme Court and a federal appeals court essentially declared Massive Resistance unconstitutional, Mr. Almond broke with the Byrd machine, turned away from the doctrine he had once supported and helped to lead Virginia on its first steps toward desegregation.