The race for Virginia attorney general dramatically mirrors the thrust of the state's politics and offers voters two candidates with widely divergent views on what the state's top legal officer should do and how he should do it.

In what is perhaps the most evenly contested race for the office in recent years, Republican J. Marshall Coleman. a 35-year-old state senator from Staunton, is challenging Democrat Edward E. Lane, a 53-year-old state delegate from Richmond.

Their race, while overshadowed by the gubernatorial contest, has been just as spirited and has evoked many of the past and present themes of Virginia politics: race, consumerism, law and order, cronyism, and conservatism.

The difference in this race, many says, is that it is the Republican who emerges as the more liberal on many issues and the Democrat who seems the more conservative. While Coleman and Lane Shun such labels, each man has made a point of seeking support across party lines.

The winner of their race will get more than a four-year salary, a $6,000-a-year expense allowance, and a state-furnished Chrysler automobile with the license plate "1-A". Both men have been mentioned as likely candidates for governor in 1981 and the winner of their race will have a clear advantage in seeking that job.

Although the lieutenant governor is officially the second ranking officer of state government, that position is only a part-time job with largely ceremonial duties. The attorney general's office, thanks to the activist role of former attorney general Andrew P. Miller, has now assumed an importance that many say is second only to that of the governor in running the state's bureaucracy.

Coleman and Lane have each pledged to keep alive the Miller tradition, and each claims that he alone can keep the office's four-member consumer unit vigorously protecting the public. Both men also voice a hard line against crime, but there the agreement seems to end.

The lanky, razor-tongued Coleman is a Vietnam veteran and is heir to the Shenandoah Valley's moderate Republican tradition. He is running what one Fairfax County Republican leader has called a "texbook classic" campaign in attempting to win by assembling a coalition of various votting blocs.

Lane, normally a subdued, behind-the-scenes legislative lieutenant, is a World War II veteran. He is heir to an arch conservative political following that has often deserted the Democratic Party and is running as the most conservative member of what the Democrats call their "Rainbow Ticket."

From the outset, the issue of race dominated their campaigns. Coleman has repeatedly attacked Lane for his support of Virginia's "massive resistance" policy of closing public schools during the 1950s rather than admit black children to white segregated schools. Lane has called his position "wrong" but has refused to apologize for it.

A state legislator since 1954 and chairman of the House Approriaptions Committee. Lane has campaigned in the region as a stauch advocate of consumer protection efforts and as friends of the Metro transit system. Citing his role as head of the House Appropriations Committee, the region's Democratic legislators have said Lane's cooperation was essential for winning a $10 million state appropriation for the system.

Consumerism has also been a major theme of Coleman's Northern Virginia appearances. But he has also used the Washington suburbs to attack Lane for what he has charged is a "clear" conflict of interest.

While in the legislature, Lane served as head of a savings and loan subcommittee and offered 21 bills affecting the industry at the same time that he held stock in and served as an officer for a Fredericksburg association, Coleman has charged. Lane has denied that he violated either the House's rules or the state's conflict-of-interest law by the actions, saying that his stock holdings were not "immediate and personal" and were allowed under the law.

Endorsed by both Miller and Anthony F. Troy, the present attorney general, Lane has charged that Coleman would gut the office's consumer protection efforts by his pledge to cut the rnumber of lawyers on the staff by 10 per cent. Coleman has contended the attorney's office, which tripled in size under Miller's seven-year reign, has been "Virginia's biggest growth industry" and needs to be trimmed in size.