The Montgomery County Council, ending 15 years of political controversy over how to cope with a growing trash problem, voted yesterday to build a $170 million trash incinerator in rural Dickerson instead of in more densely populated Shady Grove.

The 4-to-3 vote capped an often bitter debate and marked the final legislative hurdle for Montgomery's most ambitious public works project.

It was a severe blow to the 10,000 residents of Dickerson, a community with little political clout that fears its oasis of undeveloped land has become a favored location for county building projects.

Montgomery's mass burn incinerator, which could be operating in five years, will burn an estimated 1,800 tons of refuse each day, producing both energy that can be sold and ash requiring disposal. County residents will bear some of the costs of the facility, paying about $24 more annually per household on the average.

The council decision to choose the far western reach of the county over the more centrally located Shady Grove area was foreshadowed two weeks ago in a nonbinding straw vote.

But intense lobbying by citizens groups, as well as heavy politicking by Council President Rose Crenca, who favored the Shady Grove site, added suspense to yesterday's six-hour debate.

Also raising hopes of Dickerson foes was the presence at the voting session of one of their allies, council member Neal Potter, who suffered a heart attack and was absent from last month's straw vote.

Yesterday's final council action affirmed earlier decisions by County Executive Sidney Kramer and his predecessor Charles W. Gilchrist. But Montgomery officials still face complex licensing procedures, negotiations with contractors as well as a certain court battle from citizens in the Dickerson area before the project can be completed.

The Dickerson facility will be the county's solution to a crisis of mounting rubbish, estimated to reach 660,000 tons annually by 1990, and shrinking landfill capacity.

The county's only operating landfill in Laytonsville will reach capacity in 18 months, but there are plans under way already to expand it for trash disposal until the mass burner opens.

Laytonsville also will be the site, at least temporarily, for the disposal of ash from the incinerator.

Kramer, who in recent weeks has both soft-pedaled and heavily lobbied council members to select Dickerson, was present for the 5 p.m. vote. He promised later to build a plant of which the county could be proud.

Bev Thoms, of the Sugarloaf Citizens Association in the Dickerson area, reacted bitterly but with little surprise to the council action. She said the county ignored environmental risks associated with the incinerator and said the citizens group, which has fought the project for a year, will use a variety of methods, including a lawsuit, to try to stop it.

Margaret Erickson, president of the Concerned Citizens and Scientists for a Healthful Environment, a group strenuously opposed to locating the incinerator near heavily populated Shady Grove, cried after the meeting but not, she said, from relief. Her group has argued that the mass burner is unsafe for nearby residents. She said "whether Dickerson or Shady Grove . . . it is a victory for nobody today."

But that is what the decision came down to yesterday. Crenca and council member William E. Hanna Jr. waged a ferocious fight to try to sway just one other council member to change position, arguing that Shady Grove is not only cheaper but more reliable.

The Dickerson location means refuse and ash will be transported by rail 18 miles between the plant and the current Shady Grove Transfer Station near Gaithersburg, a process that Hanna and Crenca argued will be more expensive, more dangerous and less reliable because of the possibility of labor strikes and derailments.

Shady Grove offered other advantages, they said, arguing that the county already owns the land, fewer permits are required for the plant operation and the county could conceivably sell steam to heat and cool nearby buildings.

"If you list all the things, the logic of the situation is overwhelming," Hanna said.

However, the four council members who previously favored Dickerson -- Bruce Adams, Michael L. Gudis, Isiah Leggett and Michael L. Subin -- were unmoved. Adams and Gudis both said it is not good policy to locate such a facility in a heavily populated area. Subin and Leggett remained silent through much of the debate.

Crenca had the last word before she called for the vote. She said the issue came down to the influence of developers, active in last year's political campaigns, who didn't want the trash facility near their land.

"When push comes to shove," Crenca admonished the council, "go with the mob of people known as voters rather than the fewer known as developers."

Joining Crenca and Hanna was Potter.