David Vasquez, a 38-year-old Manassas man, was sentenced to 35 years in prison yesterday for second-degree murder and burglary in the slaying of Washington lawyer Carolyn Jean Hamm.

Vasquez pleaded guilty in exchange for prosecutors' agreement to drop charges of capital murder, rape and robbery. The plea bargaining agreement followed a ruling by Arlington Circuit Court Judge William L. Winston that two statements Vasquez made to investigators could not be used as evidence against him because police failed to advise him of his rights.

That ruling "greatly damaged our case," Arlington Commonwealth's Attorney Henry H. Hudson said. "We lost so much of our evidence that we felt we had to seek the best disposition that could be salvaged. I have to say I was very pleased [with the outcome], as were the family and friends of the deceased."

Hamm, 32, a lawyer with the firm of Wilkes, Artis, Hedrick & Lane, was found dead Jan. 25, 1984, in the basement of her home at 4921 S. 23rd St., Arlington, where she lived alone. She was nude, her hands were bound behind her and a rope around her neck was tied to an overhead water pipe, police said. There was evidence that someone had had sex with her shortly before or after her death, and she had died of asphyxiation two days before her body was found.

Second-degree murder, to which Vasquez pleaded guilty, is defined as murder without malice or premeditation.

Yesterday's plea and sentencing -- Judge Winston said he would recommend that Vasquez be incarcerated at a facility where he could receive psychiatric treatment -- ended a case that both prosecutors and defense lawyers described as unusually complex.

Vasquez, an employe of a fast food chain, had formerly worked as a janitor at Wakefield High School near Hamm's house and had lived in her neighborhood before moving to Prince William County in 1983.

In three tape recorded statements to police the day he was arrested, and the following day, Vasquez gave a rambling, often incoherent account of the slaying. In the second statement, a detective testified yesterday, Vasquez described "horrible dreams" about the slaying that contained details only the killer or police could have known.

At a preliminary hearing last March, Detective William C. Shelton said Vasquez told him that he bound Hamm's hands with cords cut from venetian blinds, had sexual intercourse with her, suspended her from a pipe, photographed her with a camera he found in the house and took money from her purse, which was found on the second-floor stair landing.

Winston ruled last week that the first two statements were inadmissible as evidence because detectives failed to advise Vasquez of his rights. He said the third statement, much shorter and less detailed, could be used in court because it was obtained after Vasquez had been informed of his rights.

Hudson remarked yesterday: "In my career as a prosecutor, it is undoubtedly the most complicated case I have ever taken on."

Because Vasquez's rambling statements, seemingly made in a trance-like state, created "a case encased within a dream," Hudson said, the prosecution's case "would have been a very complex mosaic of circumstantial evidence." He said the case required an estimated 350 hours of preparation and he had expected to call 40 witnesses if the original charges had been tried.

Defense attorney Richard J. McCue said Vasquez "could have received the death penalty or a sentence substantially greater than that he received" under the plea agreement had he been convicted of the original charges against him.

Vasquez will probably be eligible for parole in eight years, Hudson said.