Henry E. Hudson defeated Arlington's controversial incumbent prosecutor, William S. Burroughs Jr., in an upset yesterday, according to complete unofficial election returns.

Hudson, an independent running with Republican backing, scored a nearly 3-to-2 victory over Burroughs, a 41-year-old Democrat who has been the county's prosecutor since 1974. Hudson, 32, was previously Burroughs' chief assistant.

In another sharply contested prosecutor's race, Alexandria Commonwealth's Attorney John E. Kloch held off challenges from Republican Barry R. Poretz and independent John E. Kennahan, according to complete, unofficial returns in the special Alexandria election. Kloch, 38, a Democrat, was appointed Alexandria's chief prosecutor last February.

In a tight race for Fairfax County sheriff, Republican M. Wayne Huggins, currently the county's chief deputy sheriff, defeated Democrat Kenneth R. Wilson, a former deputy Fairfax police chief. Two independents, Christopher Stokes and James M. Settle Jr., trailed far behind.

Wilson and other Fairfax Democrats attributed Wilson's defeat to Stokes' independent campaign for sheriff. Stokes, a black, campaigned heavily and was expected to cut into Wilson's vote-getting strength in predominantly black sections of the county.

Fairfax Democratic Committee chief Emilie Miller criticized Stokes as a "spoiler" in the sheriff's campaign. "Stokes is taking votes away from Wilson," she said. "The black community supporting Stokes is going to be the biggest loser."

Huggins later claimed victory, pledging to "work my heart out" as sheriff. "I haven't had a more happier moment in my entire life," he said. Then he embraced his mother. Huggins declined to say whether he believed Stokes' campaign had helped him win.

In Loudoun County, incumbent Sheriff Robert W. Legard, 50, a Democrat, was defeated by a former deputy sheriff, Donald L. Lacy, 32, a Republican. Thomas D. Horne, a Democratic assistant prosecutor, beat Jean H. Clements, a Republican lawyer, in the Loudoun prosecutor's race.

Races for prosecutor and sheriff have been among the hottest political contests in Northern Virginia this fall. In Arlington, Fairfax and Loudoun counties and in Alexandria, several key campaigns have taken place against a backdrop of controversy, criminal investigations and scandal.

A central issue in the Arlington prosecutor's race was a continuing controversy stemming from a complex 1977 double-murder case. Hudson contended that incumbent prosecutor Burroughs mishandled the murder investigation and charged that Burroughs was frequently at odds with local and state law enforcement agencies. Burroughs denied his opponent's charges and claimed considerable success in his five years as county prosecutor.

Hudson claimed victory last night, promising to support "our police department and law enforcement system."

The Fairfax sheriff's campaign took place amid widespread controversy centering on outgoing sheriff James D. Swinson, who is retiring after 16 years in office. Recent investigations of the sheriff's office disclosed misuse of jail inmates, put to work by deputies as unpaid laborers outside the jail. Swinson was also sharply criticized because of the deaths of three inmates last year after confinement at the Fairfax jail.

Huggins, Swinson's chief deputy and chosen successor, called Swinson "the best sheriff in Virginia" and defended him against the criticism. Huggins' three opponents repeatedly sought to capitalize on the criticism surrounding Swinson's office raising charges of impropriety, cruelty to prisoners and administrative ineptitude.

The Alexandria prosecutor's race took place under a cloud left by former prosecutor William L. Cowhig, who resigned last February during a bingo scandal. Cowhig stepped down after being acquitted in two trials of bribery and gambling charges. A third gambling indictment against him was dropped. The special election is designed to fill the remainder of Cowhig's term, ending in 1981.

Kloch, Cowhig's former deputy and court-appointed successor, sought to defend himself against his opponents' charges by asserting he was unaware of the allegations involving Cowhig until they surfaced publicly. Kloch stressed his campaign endorsement by Alexandria's former special bingo prosecutor, Edward J. White.

Kennehan, a former Alexandria prosecutor, attacked Kloch as Cowhig's "hand-picked deputy" and charged that "a heavy cloud of suspicion" hung over Kloch because of the bingo scandal. Poretz campaigned on a slogan of a "new direction" for the prosecutor's office.