Thomas W. Moss Jr. presiding over the Virginia House of Delegates in 1999. (Gerald Martineau/The Washington Post)

Thomas W. Moss Jr., one of the most powerful members of the Virginia House of Delegates during his 36 years as a legislator, including nine years as House speaker, died Nov. 26 while visiting relatives in Greenville, S.C. He was 87.

He had a heart attack at a Greenville hotel, said his wife, Norma Moss.

Mr. Moss, a lawyer, was first elected to the House in 1965, representing a district in Norfolk. The Democrat was reelected ­every two years for a total of 18 terms.

He spent 11 years as House majority leader before he was elected speaker in 1991. He was the last Democrat to hold the position in Virginia.

When he first ran for office, Mr. Moss was a reform candidate, opposing the conservative machine led by U.S. Sen. Harry F. Byrd Sr. (D), which was known for its staunch attachment to segregation. Mr. Moss campaigned under the slogan “Get Norfolk out of the Byrd cage.”

In his first term, Byrd’s supporters exiled the newcomer to a remote desk in the House chamber and assigned him to committees so toothless, Mr. Moss said, that “none of those committees had met since the War Between the States.”

As he became more entrenched in Richmond, he was recognized as an “orator extraordinaire,” according to the Roanoke Times, and as a legislator who favored humor and camaraderie over strong-arm tactics. At a time when Democrats dominated the legislature, Mr. Moss spearheaded measures to benefit the commonwealth’s ports, to improve conditions for mental patients and to increase support for education.

He steered projects worth hundreds of millions of dollars to Norfolk and the Hampton Roads region. The Norfolk campus of Tidewater Community College is named for him.

Mr. Moss was sometimes criticized for promoting legislation favored by his legal clients — a charge he adamantly denied — and for being insensitive to women’s issues.

In 1992, when the House was debating a bill about fox hunting, Mr. Moss remarked, “If the gentleman says he’s never been to a fox hunt, he’s never been to the bar at the Holiday Inn downtown.”

Female legislators told him his comments were out of line.

“Moss often has been a fixture at the aforementioned Holiday Inn,” a Washington Post story noted, “the favored legislative ­watering hole, where he is known to belt out ‘Danny Boy’ when particularly relaxed.”

Thomas Warren Moss Jr. was born Oct. 3, 1928, in Norfolk. His father was a paper salesman.

Mr. Moss graduated from Virginia Tech and received a law degree from the University of Richmond. He served in the Army during the Korean War.

In 1998, when the House of Delegates was evenly divided between Republicans and Democrats, Mr. Moss won reelection as speaker in a rancorous contest in which Republican delegates pounded on spittoons at their desks and made frog-like croaking sounds.

Even so, both parties praised Mr. Moss for his evenhanded way of making committee assignments.

Instead of running for reelection to the House in 2001, Mr. Moss was elected city treasurer of Norfolk. He held the position until his retirement in 2014.

His marriages to the former Jane Miller and Lorna Payne ended in divorce.

Survivors include his wife of 12 years, Norma Dietrich Moss of Norfolk; two children from his first marriage, Thomas W. Moss III of Virginia Beach and Elizabeth Adamson of Richmond; a stepson; and nine grandchildren.

A daughter from his first marriage, Susan Moss Bernhardt, died in 2011.

During his legislative career, Mr. Moss led efforts to repeal some of Virginia’s old “blue laws,” which placed sometimes curious restrictions on the state’s dining, drinking and social habits.

In 1976, he sponsored a bill to allow restaurants to serve alcohol to customers who were standing. (The old law required Virginians to be seated while drinking or being served alcohol.) When one delegate denounced the bill as “a further step toward bars,” Mr. Moss — admittedly no stranger to the tavern — said, “I still say you can’t drink as much standing up as you can sitting.”

The bill passed.