President Reagan, whose popularity in conservative Virginia remains unchallenged, put his political prestige on the line tonight for J. Marshall Coleman, the Republican candidate for governor.

The president, hoarse but upbeat, told an enthusiastically partisan crowd of more than 1,000 that Coleman's election was vital because "it isn't going to do us any good to clean up the mess in Washington unless the right kind of candidates are elected to state governments."

Reagan was here for little more than an hour, but that was long enough to fire up Virginia's Republican loyalists, who face an uphill battle in making Coleman, trailing in the polls, the state's fourth consecutive Republican governor. The president told them that the election contest between Coleman and Democrat Charles S. Robb boils down to a choice "between time-honored beliefs and an uncharted course of conduct which has led us far from the concept of sovereign states."

Reagan took another sharp jab at Robb, who has portrayed himself as a fiscal conservative comfortable with the president's programs. Said Reagan: "As an ex-Democrat, I never cease to be amazed at how conservative liberals can sound in election years."

Coleman got a second boost tonight when he received a long-awaited blessing from two-time Virginia Gov. Mills E. Godwin, spiritual leader of the state's independent conservatives. Characterizing next week's election as a referendum on Reagan, Godwin warned: "Make no mistake, whether true or not, Reagan's opponents would hail a Robb victory as a sign of the president's weakness."

Coleman has sought from the beginning to make the election a Reagan popularity contest and had waited eagerly for a presidential appearance on his behalf. Reagan was forced to bow out of an earlier appearance last month to make a televised appeal for new federal budget cuts.

To counter the President's appeal, just minutes after Reagan left the meeting hall at the John Marshall Hotel here tonight, Robb's own conservative supporters staged a rally in a hall across the lobby. There W. Roy Smith, a Godwin ally and former state legislator, praised Reagan before the audience of about 600 but said Virginia needs a governor "with an open mind . . . not someone who is riding on someone else's coattails."

In his speech, Reagan took note of the charges and counter-charges made in this most expensive gubernatorial campaign in Virginia history, urging voters to "carefully examine the records of the two candidates . . . free of the glare of advertising, in quiet reflection, ignoring the image building that has characterized this campaign."

A beaming Coleman, a one-time maverick state legislator who has struggled for acceptance from his party's elders as well as from the voters, basked in tonight's praise from the president and from many of the brightest stars in the state Republican constellation. Besides Reagan and Godwin, Gov. John N. Dalton, U.S. Senator John W. Warner and three members of the Virginia House of Representatives delegation were on hand.

Reagan also boosted Coleman's running mates, Nathan H. Miller for lieutenant governor and Wyatt B. Durette for attorney general, urging party workers to "give us a team that will do what needs to be done."

Except for those given the president, the loudest cheers of the night went to Miller, who gave a rousing speech in defense of his controversy-plagued campaign. Miller dismissed conflict-of-interest charges against him as smear tactics and vowed, "I shall fight political enemies one at a time or all at once." The boyish state senator said commercials that have "attacked my honesty, religion, integrity" had "a sick similarity" to ads employed in 1964 by Robb's late father-in-law, President Lyndon B. Johnson, to assert that Republican Barry Goldwater would lead the nation to nuclear war.

From Dalton to Coleman to Godwin, speaker after speaker hammered at racially tinged issues such as the Voting Rights Act and the moribund D.C. Voting Rights Amendment in outlining the differences between the candidates.

Godwin, whose personal distaste for Coleman has been a poorly concealed secret throughout this campaign, had little to say about his party's nominee tonight. He lashed out instead at Robb's support of the Voting Rights Act, contending that extension of the key federal civil rights legislation of the 1960s "would keep this state in bondage to the Department of Justice." He called voter registration by mail, which Robb also supports, "an engraved invitation to political fraud."

Godwin also attacked Robb for supporting past Democratic standardbearers such as Jimmy Carter and George McGovern, and asked "Do we in 1984 want to watch the chief official of our commonwealth make common cause with Teddy Kennedy or Walter Mondale?"

At his own rally later, Robb said the critical test of the election was not which candidate had the support of Reagan, but which one could work best with the Democrat-dominated General Assembly. He dismissed the racial implications raised by the Republicans, warning the state "cannot become confused by the litmus-test issues that would divide us . . . we simply cannot permit ourselves to move backward."

Earlier today, Robb swung through the Washington suburbs and conceded that the combination of Reagan's visit and Godwin's endorsement would probably boost Coleman by one or two percentage points.

"It's clear that President Reagan is very popular in the state, and that's why Coleman is making every effort to just wrap himself in the coattails of the president," Robb said.

The Democratic nominee did not appear troubled at the prospect of such a gain, or by Republican claims that Coleman is now leading by two percentage points. A newspaper in Richmond last weekend put Robb's lead at nine points.

"I would hope that most Virginians won't have their attitude shifted from the real issue in this campaign, which is who will provide the best leadership of Virginia for the next four years," Robb said.

While there was no charge for tonight's Richmond rally, with loyal supporters invited by mailgram from across the state on a first-come, first-served basis, the president's appearance was expected to spur contributions to a campaign that already has spent $2.29 million, and is in debt by $250,000, in addition to having borrowed $190,000 in the last month.

Coleman's new report of campaign contributions and expenditures, released today, revealed loans of $150,000 from the United Virginia Bank of Richmond and $25,000 from Richmond financier Lawrence Lewis Jr.

Also contributing to this article was Washington Post staff writer Patricia E. Bauer.