Top Virginia Democrats moved to end a potentially divisive feud today that erupted this weekend after the state's labor leaders endorsed Lt. Gov. Richard J. Davis for governor.

The endorsement by the 37-member AFL-CIO executive committee brought a heated charge from campaign aides for state Attorney General Gerald L. Baliles, who charged that Davis received labor's support by promising to back collective bargaining for state government employes.

The practice is prohibited by state law and considered politically risky in conservative Virginia, where organized labor has 104,000 members and limited political power.

Davis, who had been expected to get the AFL-CIO endorsement, angrily denied the Baliles accusation and threatened to pull out of the Democrats' annual Jefferson-Jackson Day unity dinner in February if Baliles didn't apologize. Baliles refused to back down, but provided no clear evidence of his campaign's charge.

State Party Chairman Alan A. Diamonstein huddled with Davis' aides and Baliles today and then called a press conference to announce that both sides had agreed to drop the dispute. "I have been assured . . . it's finished," said Diamonstein.

Diamonstein, a delegate from Newport News, said he had not tried to determine which side was telling the truth, but stressed that continued attention to the issue could hurt the party in next year's campaigns.

Davis' aides said later that he will remain as a cosponsor of the February dinner and Baliles issued a statement saying it was a time of Thanksgiving and that the party should be unified.

The Democrats will select their nominees for governor, lieutenant governor and attorney general at a Richmond convention in June. They will begin choosing convention delegates as early as March. Party leaders said union members are expected to represent about 15 percent of the 3,500 delegates who will be selected.

A third Democratic candidate for governor, Del. Richard M. Bagley of Hampton, who had sought the labor endorsement, was not involved in the dispute. Russel Rosen, Bagley's manager, said Bagley respected the decision of the AFL-CIO executive committee, but would continue to seek support from labor members.

Largely obscured in the flap was the committee's simultaneous and unanimous endorsement of State Sen. L. Douglas Wilder of Richmond for the Democratic nomination for lieutenant governor. Some Democrats have expressed concern over Wilder's candidacy, citing fears that the state's white voters will not support a black nominee and that Wilder would hurt the ticket.

The labor federation, which initially voted 28 to 6 to endorse Davis and later made it unanimous, rejected suggestions that the early endorsement would appear similar to the early endorsement Walter F. Mondale received from the national AFL-CIO in October 1983. Some Democrats said that action continued to hamper Mondale's presidential campaign against President Reagan.

"It gives us time to get things in order," said Virginia AFL-CIO President David Laws, a Davis ally.