Bank of Vienna directors, who had resisted a takeover bid by the Bank of Virginia for several months, recommended the offer to shareholders yesterday, two weeks after the big Richmond bank boosted its offering price from $31 to $40.

Bank of Virginia has said that it will accept shares in the suburban Washington bank until Dec. 16 and on that date will pay all stockholders who have tendered their shares.

Acceptance of the Bank of Virginia offer climaxes a year and a half of internal squabbling at the Bank of Vienna that pitted the bank's chairman, H.E. McCarty, and several other directors against Michael Juhasz, the bank's former chairman and its largest shareholder.

The internal fighting led Juhasz and nine other shareholders to contract to sell their holdings to the Bank of Virginia last June. Bank of Virginia, with 21 percent of the Bank of Vienna's stock under contract, launched its takeover bid last August after it could not arrange a friendly merger with the small bank.

Dominion Bankshares Corp. then made a friendly, $35-a-share merger proposal that Bank of Vienna directors embraced and then rejected after Central Fidelity Banks made a $40 merger bid.

But when Bank of Virginia received regulatory approval to buy the bank -- something Central Fidelity was probably months away from obtaining -- the big Richmond bank boosted its offer to $40. Sources close to the bank said directors changed their minds about resisting the offer because Bank of Virginia could pay immediately.

Bank of Vienna director Douglas Bywater said that although most directors would have preferred that the $25 million bank remain independent, hopes of maintaining that independence evaporated when Juhasz and other shareholders agreed to sell to Bank of Virginia.

The board fight was touched off in June 1981 when directors learned that President McCarty and several other directors and bank officers quietly formed a partnership that bought about 3,000 shares of Bank of Vienna stock in the spring of 1981. The partnership paid between $16.75 and $17.50 a share. Several shareholders who sold to the partnership unknowingly have sued to recover their shares -- now worth $40 -- at the price they sold them for in 1981.

The partners who bought the stock have told other directors they did so in the hopes of keeping the bank stock in friendly hands to preserve its independence, keeping stock they knew was up for sale from falling into the hands of a big, acquisition-minded, downstate bank.

Their lawyer, Fairfax attorney Wyatt Durrette, said in a recent interview that there was no market for Bank of Vienna stock at the time the partnership made its purchases and that the six partners "thought they were doing a good deed for the bank and its shareholders."