The Virginia Senate narrowly defeated today a controversial annexation bill aimed at resolving what one senator called "the constant squabbling" between the state's cities and counties over their boundaries.

Within hours of the 20-to-17 rejection of the annexation measure, senate supporters of the bill got their colleagues to agree not to report defeat to the legislation officially to the House immediately.

Through this parliamentary tactic, Senate supporters of the House-passed annexation bill hoped they could regroup and win passage of it on Thursday.

The annexation legislation, which has generated some of the most spirited debated in the 1977 General Assembly session, calls for creation of a complex system of revenue sharing under which counties could gain immunity from annexation by cities and towns by paying a "tribute" to neighboring jurisdictions.

While not officially informed of the Senate defeat of the annexation bill, angry House members retaliated and sent to the Senate a measure that would extend the state's current - and equally controversial - ban on annexations for another 10 years.

"This will put pressure on the Senate" to reconsider its rejection of the over-all annexation bill, said Del. Donald G. Pendleton (D-Amherst). "If they know they're facing a bill giving a 10-year moratorium on annexations, maybe they'll come around to the great wisdom of the House," he said.

The moratorium measure passed by a 71-to-25 margin despite the assertions of some House members that the bill would end any chance of thre state's resolving the annexation controvery and would, in the words of one delegate, "do away with annexation."

But Del. C. Richard Cranwell (D-Roanoke) countered that the Senate's action indicted the Assembly was "incapable of dealing with annexation" and urged that the next moratorium be a long one. "If we're going to be in purgatory, let's stay around long enough to see if we like it," he said at one point.

In a House speech, Cranwell blamed the Senate defeat of the bill on city "empire builders" unwilling to give up further annexation court fights and suburban government leaders unwilling to help the state's core cities.

Then, in an apparent reference to rumore of vote-trading among senators, Cranwell added "Now that the budget bill has passed, there may not be any more money floating around to defeat" attempts to reconsider the main annexation bill.

Although Cranwell was not more specific, Senate Finance Committee Chairman Edward E. Willey (D-Richmond) last week denied in a floor speech he was trading votes in an effort to kill the annexation bill. Willey conceded, however, that he was seeking "a little kindness" from other senators in return for budget measures he had previously supported for their regions of the state.

The House's action came on a Senate-passed bill that had been approved in an effort to have a way of continuing the current six-year moratorium if the annexation bill failed.

The bill was defeated in the Senate after more than an hour of sometimes emotional debate that includes a reading from the Bible and frequent predictions of disaster should the measure pass or fail, depending which side the speaker was espousing.

Some senators, such as Willey, said they were against the measure because it would allow counties to acquire immunity from annexations, and thus prevent a city from increasing its tax base by expanding.

Others said they were opposed to it because counties would have to pay "blackmail" - the revenue sharing - to keep their size intact.

The bill's supporters including Sen. Joseph V. Gartlan (D-Fairfax), argued that the bill was the "fairest" solution toward resolving the conflict.

Most of the debate focused on the question of how to solve the problems of inner cities facing declining populations and increased governmental costs.

"There is no question that the cities of this state need help," said the leader of the fight against the bill Sen. Frederick T. Gary (D-Chesterfield), who represents a county that is bordered by four cities. "They act like magnets to the poor and disadvantaged, who have no job skills and are attracted by the free clinics, public housing and the night life that lets them escape the miseries of their poor environment. But this annexation bill is a Band-Aid over the problem."

An underlying but rarely mentioned theme on the annexation question is race, as whites have fled to the suburbs and blacks remain in the cities. "No one has addressed the black-white question," said Sen. Dudley J. Emick (D-Botetourt) who voted for the bill, "but that is the great problem that is at the root of it all."