Virginia Republicans rebuffed both their party's leaders and the Christian right tonight by selecting a little-known state legislator as the running mate for gubernatorial nominee J. Marshall Coleman in the November elections.

Delegates to the GOP's state nominating convention acclaimed Coleman, the state attorney general, as their nominee to face Democrat Charles S. Robb, but they turned aside plans from their leadership and backers of a born-again ally of television minister Jerry Falwell to pick state Sen. Nathan Miller, 37, a boyish-faced Shenandoah Valley lawyer, as their nominee for lieutenant governor.

The battle for the No. 2 spot raged for four divisive ballots and included cries that the forces of Gov. John N. Dalton and former Gov. Mills E. Godwin were attempting to "steal" the nomination for state Sen. Herbert H. Bateman, a former Democrat from Newport News. While Coleman kept his pledge to remain neutral in the bitter contest, many of his closest supporters worked for Bateman.

The stage for Miller's victory was set after a third candidate, Guy O. Farley, a fundamentalist Christian, withdrew at the end of the third ballot. At that time, Bateman was leading with 1,461 votes, Farley was a steady second with 1,235 and Miller last with 651 votes, and seemingly fading. s

Farley, considered anathema to most party leaders because of his close ties to Falwell, had come to the convention as the front-runner, and held a slight lead after the first ballot.

But his sudden withdrawal, after hanging close to Bateman for three ballots, caught the party's leadership off guard, and sent the delegates into a convulsion of meaneuvering and vote switching. Although Farley gave his loyalists no instructions, hundreds of them took part in a dramatic shift to Miller, who by then had seemed out of the running.

"This whole Godwin group overdid it, and that's why the Farley group went to Miller," said Fairfax Del. Vincent Callahan, a Miller supporter. "They didn't like someone trying to ram a candidate down their throats."

Minutes after Miller's stunning win, the GOP ticket of Coleman, Miller and Wyatt Durette of Fairfax, who was unopposed for attorney general, was on the podium, hands upraises in a try for unity which had been the theme of the two-day convention.

After the bloody show, which went 11 hours today without a break, the Republicans had in Miller the most aggressive of the three men who had sought the number two spot. But they were also left with a ticket that lacks the geographical balance that Godwin said, in nominating Bateman, was critical to beating the Democrats in the fall.

Miller, like Coleman, comes from the Shenandoah Valley, denying the GOP any candidate from either the populous Tidewater or Richmond areas.

The riotous ending tonight stood in stark contrast to the carefully controlled and orchestrated Democratic convention, held in the same hall last weekend. The Democrats' tickets includes Robb from Northern Virginia, Richard Davis from Portsmouth for lieutenant governor, and Gerald Baliles from Richmond for attorney general -- a geographic mix that GOP leaders said tonight will be a definite plus in the fall.

Coleman, 38, who became the first Republican attorney general in Virginia history four years ago, sought to downplay suggestions that tonight's open warfare would hurt his chance of carrying on 12 years of Republican leadership in the Governor's mansion. "By the end of the night, everybody will be united again," said Coleman.

But many party leaders said the repudiation of Dalton and Godwin, both of whom bolted from the hall after Miller's nomination, will require considerable fence-mending.

Miller's upset win overshadowed Coleman's unopposed nomination earlier in the day, and his rousingly partisan attack on Robb, 41, son-in-law of the late president Lydon B. Johnson. "The Democrats are saying this year, 'We've changed; we are different,'" Coleman said. "I know they're trying to change, but they look just the same to me."

And Coleman took a swipe at Robb's relationship to the Democratic president, saying "They may get their candidate right out of the Great Society, but they'll never get the Great Society out of their candidate."

Dalton and other party leaders had considered Farley, whose campaign was directed by former operatives of Ronald Reagan's landslide 1980 Virginia win, the man to stop. They thought they had succeeded after the third ballot, when Bateman pulled ahead by more than 200 votes.

But Farley's withdrawal, which caught both camps by surprise, dramatically changed the situation.

Miller then began to surge. With all but one of the convention's 10 districts having recorded their votes on the fourth ballot, he was within 35 votes of the nomination. Bateman already had acknowledged defeat, draping his arm over his son's shoulder and telling friends, "It's over."

Suddenly, Bateman was tugged to an impromptu meeting of the Chesapeake delegation, whose chairman, Burt A. Bobbit, still was trying to get his group to vote unanimously for Bateman. "Try to find Mills Godwin," said Bobbit, unaware that the former two-term governor, who had nominated Bateman, had left the hall, convinced his candidate had lost.

Godwin returned to participate in a backroom summit with Bateman, Dalton and other members of the party hierarchy.

Meanwhile, on the floor, Miller's delegates were chanting and screaming to end the delays. "They'll steal it from you, Nathan." Abraham Chocklott, a Botetourt County delegate, yelled to Miller, "Godwin and his crowd are going to take it away."

There were cries of "impeach the chairman" from Miller supporters as convention chairman A. Joe Canada, a Virginia Beach state senator, ruled that delegates whose votes already had been counted could change them.

Behind the podium, in a last-ditch move to sway the former Farley supporters, Bobbit allowed Miller to enter the closed Chesapeake caucus, and then demanded that Miller agree to a constitutional amendment banning abortion. Miller, who has opposed any state funding for abortion, refused, as did Bateman.

With that, the stop-Miller effort collapsed. Bateman, Godwin and Dalton agreed the cause was lost, and the voting was completed, with the fourth district giving Miller 99 votes, putting him over the top. The final total was 1,744 for Miller to 1,541 for Bateman.

"The Dalton, Bateman, Godwin crowd who so proudly announced a stop-Farley movement had it blow up in their faces," said Shenandoah Del. Clinton Miller, no relation to the nominee.

Today's nomination capped an almost meteoric political rise for Coleman, who just five years ago was regarded as an outspoken, but politically inexperienced state lawmaker from the Shenandoah Valley.

Four years ago, he surprised many party leaders by capturing the attorney general's nomination from Durette. He went on to become the first Republican to win the office of state attorney general, defeating conservative Democrat Edward Lane of Richmond, a former segregationist in an election that won Coleman backing from many liberals. He has been the party's gubernatorial heir apparent ever since, despite complaints about his conservative credentials by some old guard leaders.

Today there was no hesitation among the GOP enthusiasts here. When Coleman asked a series of questions about whether Robb had supported Republican candidates Gerald Ford, Dalton and Reagan, he got the expected chorus of resounding "no" answers.

Coleman lumped Robb in the company of losing Democrats Jimmy Carter, Elmo Zumwalt, Henry Howell and Andrew Miller, and said the claims of Virginia Democrats that they have changed "reminds me of piece of down-home Shenandoah folklore -- maybe a duck can change its quack, but it will never change its waddle."

Dalton in his speech nominating Coleman also attached Robb's LBJ connections, suggesting Robb had advanced by living off the wealth of others while Coleman had "worked his way up -- he's doen it on his own and no other candidate for governor can make that statement."

It was a day highlighting the contrasts between the Republicans and the Democrats who held their convention here just a week ago. More than 7,000 Republicans jammed the hall -- nearly twice the number of Democrats who had been here. One count showed no more than 50 blacks among the GOP, compared to about 400 among the Democrats.

The freewheeling atmosphere and uncertainty over the lieutenant governor's contest also differed from last week, when Robb's forces kept a tightly controlled grip on the floor. "It's ironic -- the Democratic convention was what you'd expect from the Republicans while this one is more like the Democrats," said Democratic strategist Paul Goldman, a visitor today.

Rep. Caldwell Butler of Roanoke, seconded the nomination of Bateman, but many of the elected officials opted publicly to follow Rep. William Wampler's "oath of neutrality." Rep. William Whitehurst of Norfolk put it bluntly: "I don't want to step in any mine fields."

The boyish Miller, looking little older than three years ago when he clung to hopes for a senatorial nomination through five ballots, was the first to be nominated.

Miller said he can "out-campaign Davis," whom he derided as a liberal who has been retrofitted with conservative principles because conservatism has become the popular thing.

Linwood Holton of McLean, the first Republican to win the governor's office this century, marveled at the overflow GOP crowd and recalled the days "Republicans had not much money and not much hope -- we had more people at dinner last night than nominated me for governor in 1965."

We well scripted demonstration following Coleman's nomination was subdued compared to the one Robb got on the same floor a week ago. But the Republicans one-upped their rivals with the introduction of a catchy campaign song that repeats the Coleman theme, "We've got a good thing going."

A visitor today was Allan C. Levey, Republican chairman of Maryland who was wide-eyed at the size and spirit of the crowd. "This is real grass roots politics," said Levey, who would like Maryland Republicans to hold an endorsing convention next year, when nominees for both governor and senator are selected.