When Virginia Attorney General Anthony F. Troy was still chief deputy to the state's top lawyer in 1976, it fell to him to defend what everyone agreed was a confusing state election ballot against legal challenges by both Republicans and Democrats.

As he stepped off an elevator outside the state Supreme Court chambers on his way to make his arguments, he saw the lawyers for both major parties and a crowd of disgruntled party officials waiting for him.

Turning to a reporter, he said, "It looks like you could call this case, "The People vs. The Commonwealth of Virginia'."

He successfully defended the ballot, devised by his client, the State Board of Elections, but he never lost his sense of regret that the state's lawyer is not always perceived as the people's lawyer.

A few months after the ballot case, Troy was appointed attorney general by the General Assembly to succeed Andrew P. Miller, who resigned to run for governor and lost the Democratic primary. Troy goes out of office Saturday after a year in which he surprised the state government and legal establishment by his aggressive actions, many of them intended to establish the attorney general in the public mind as the people's lawyer.

By concentrating on antitrust cases and by squeezing what he could out of the meager consumer protection resources of the office, Troy has filed suits and launched investigations against a handful of alleged price fixing schemes.

He also has successfully resolved a number of consumer complaints, including the Virginia portion of nationwide complaints against General Motors for substituting lower priced engines in higher priced cars.

"It still troubles me that much of the public preceives a difference between the state's interest and the public interest," he said in a recent interview.

"We are the state's lawyer, but we represent the public interest. We have no interest separate from the public."

Troy said he sees the state as "playing more of an affirmative" role for the public in the future and cites antitrust actions as one example.

His antitrust staff, even after a recent expansion, still consists of only three lawyers and one investigator. However, in the last year, it has reached out-of-court agreements that ended what the office considered anti-competitive practices by real estate multiple listing services, price fixing by barbers and price fixing by fast food franchisers.

The antitrust unit also has sued in several important cases when it was unable to reach settlements. Suits are pending against funeral directors that the office alleges have boycotted an inexpensive interment service and against sugar refiners and plywood manufacturers supplying Virginia state and local governments.

Troy recently announced that his office and the Department of Motor Vehicles are investigating allegations of widespread odometer tampering by used car dealers. It is charged that the mileage indicators of late model used cars are turned back by some dealers to increase the market value of the cars.

The odometer investigation also offers the prospect of consumer relief through the antitrust laws. Criminal penalties for odometer tampering provide only for a $500 fine and a maximum of one year in jail. However, under the Virginia Anti-trust Act, the attorney general will be able to seek up to $100,000 in fines and under federal law can seek payments to individual consumers of up to $1,500.

Troy and his predecessor, Miller, were among the state attorneys general in the country who lobbied Congress in the face of business opposition for the right to sue on behalf of state residents under federal antitrust laws.

As chairman of a subcommittee of the National Association of Attorneys General, Troy also helped states win a federal grant to expand their antitrust enforcement. Virginia will get $200,000 a year for the next three years for its small antitrust staff.

Troy, as was Miller, is a promoter of an expanded role in public legal representation for the National Association of Attorneys General partly because he believes these elected officials will get results faster than the federal bureaucracy.

As his principal example, Troy cites the GM engine substitution case. When it was disclosed that GM was putting Chevrolet motors in higher priced cars without telling customers, the Federal Trade Commission put the case in its investigative mills but state attorneys general began filing suits against the carmaker all over the country.

A committee of the state lawyers finally worked out a settlement with GM, agreed to at the mid-winter meeting of attorneys general in San Francisco last month. Under the settlement terms, each aggrieved car buyer will receive $200 in cash and an extended warranty worth $200.Troy said the 1,650 Virginians affected could receive as much as $660,000.

Despite his vision of his job as lawyer for the people, Troy said the attorney general's duty to defend laws passed by the General Assembly and policy decisions by the governor inevitably will continue to cast the officeholder in the role defending the state against popular causes.

Troy has done his share of defending the state against actions brought for minorities and others with a grievance against the government.

As the state's lawyer, he is resisting federal efforts to force the state police to hire more black troopers. He also has defended the state's educational program for handicapped children against charges by parents that it is so deficient it does not meet state and federal standards.

In addition to defending the confusing ballot of 1976 he also has argued that the state offers adequate opportunity to register to vote in the face of claims by some Democrats that it does not.

Former Lt. Gov. Henry E. Howell, the unsuccessful Democratic candidate for governor last year, sued the state on the registration issue. However, he later withdrew his complaint, saying that Troy had helped arrange sufficient registration opportunities.

Troy also has issued some cotroversial opinions that do not have the force of law but usually are adopted as policy by state agencies affected by them. For instance, his recent opinion that state employee salaries and pensions are covered by the Virginia Privacy Act and not the Freedom of Information Act has made it difficult even to learn the pension that outgoing Gov. Mills E. Godwin will receive.

Troy, 36, is a Democrat who is thought to be a likely house of Delegates candidate in 1979, but will be returning to a purely private life on Saturday. He promised before his appointment last January not to seek election to attorney general last year.

When he leaves office, he will become a partner in the same large Richmond law firm that Miller joined after losing the Democratic gubernatorial primary last June.