Virginia Democratic legislator Richard M. Bagley of Hampton abandoned his long-shot campaign for governor today, narrowing the race for the party's nomination to what is expected to be an intense battle between the state's attorney general and lieutenant governor.

Bagley, who has been seen as a potential candidate for lieutenant governor, all but ruled himself out of that contest as well and said in an interview that he would seek reelection to the House, where he is chairman of the powerful Appropriations Committee.

Bagley, 57, considered the most conservative Democrat in the race, said his own poll of potential delegates to the party's June 7 nominating convention in Richmond showed him badly trailing Lt. Gov. Richard J. Davis of Portsmouth and state Attorney General Gerald L. Baliles of Richmond.

Bagley ended his 11-month bid one day before the campaign kickoff of Davis, 63, the party's acknowledged front-runner.

Baliles, 44, is expected to announce in early January and is thought likely to be endorsed by Bagley, campaign aides said.

Aides to both Davis and Baliles sought to lay claim to supporters of Bagley, who said he was unable to expand his support significantly beyond the legislature, where he has served since 1966.

Bagley supporters said their recent poll of 400 likely delegates to the party nominating convention showed Bagley a distant third, while Davis held a lead of nearly 20 percentage points over Baliles.

About 30 percent were undecided in the poll, taken shortly after the Nov. 6 elections.

Campaign sources said that a key finding of the poll was that about 50 percent of the potential delegates to the convention were likely to be more liberal than the generally conservative-to-moderate Virginia electorate.

That factor is considered likely to help Davis, who is viewed as being more liberal than Baliles, in the nomination fight.

"There's still a contest," one Bagley aide said of the remaining Davis-Baliles matchup. "The support is unstable."

The aide suggested, however, that Bagley, widely perceived as the second choice of both Baliles and Davis supporters, in fact was unable to position himself strongly enough to tap potential political support, despite building a campaign war chest that recently approached $300,000.

Aides said Bagley failed to make inroads into Davis' support among teachers and others, despite a bold proposal to raise state taxes next year to provide $300 million in revenue for education. Bagley also is known as a major architect of efforts to improve the state's mental health system.

Baliles and Davis got into a public scrap late last month when Baliles accused Davis of winning the endorsement of state AFL-CIO leaders by pledging to support collective bargaining for government employes in a state known for its right-to-work laws.

Davis called the charge "a damn lie" and the incident was smoothed over only after intervention by state party Chairman Alan A. Diamonstein.

Other Democrats have feared the Davis-Baliles fight could worsen as the party nears its spring mass meetings to select convention delegates.

"It has been no secret from the outset that it would be an uphill battle . . . ," Bagley said at a news conference today. Despite nearly 20 years of experience in the legislature, Bagley said, "politics is still the art of the possible."

Russell Rosen, a former executive director of the state party and Bagley's campaign manager, suggested later today that Democratic Gov. Charles S. Robb, who under Virginia law is not allowed to succeed himself, should become more involved in the party's nominating contests.

Rosen warned that the party could be headed for a divisive convention struggle between Baliles and Davis amid racial polarization over the potential nomination of L. Douglas Wilder, a black state senator from Richmond, as lieutenant governor.

"I think the governor, as leader of the party, should take an active role in coming up with the best possible ticket," said Rosen, one of several former and present leaders of the party who urged Robb to abandon his public hands-off role in the campaigns.