The Montgomery County Council voted yesterday to withhold $118,000 from the city of Takoma Park to pay for fire and rescue services the county provides. But within hours, city lawyers filed suit in Circuit Court, charging that the action was illegal.

The vote and the suit were the latest developments in an eight-year-old tug of war between Montgomery and Prince George's County over who should pay for fire service in Takoma Park, which straddles both jurisdictions.

"Believe me, we've spent a great deal of time trying to resolve this problem. We did not take this action lightly," said Council President Michael Gudis.

"We're saying they didn't comply with county or state law," countered Takoma Park City Attorney Thomas Gagliardo.

About one-third of Takoma Park lies in Prince George's County, but Montgomery County, where the rest of the city lies, provides fire and rescue service for all city residents.

Under a 1974 agreement, Montgomery took over Takoma Park's fire station and Prince George's assumed part of the cost of its operation. But in 1978, Prince George's abruptly stopped paying its share, and both sides have been squabbling ever since.

Prince George's County provides a tax credit to city residents to cover the cost of fire service, but Montgomery officials say that the Takoma Park government has consistently refused to pass the money back to Montgomery County. To do that, the city would have to set up a special tax district. Gagliardo maintains the district would be illegal, despite a legal opinion to the contrary by Montgomery County Attorney Paul McGuckian.

The Montgomery council voted yesterday to deduct the $118,000 from $587,000 it owes Takoma Park under a 1982 state law that prohibits the "double taxation" of city residents for services provided by the city instead of the county.

The suit argues that the county does not have the authority to deduct the money and asks the court for a declaratory judgment to force the payment. A hearing has been set for later this month.