Exhibit 5 June 3, 1999 The Board of Directors National Bankshares, Inc. 100 South Main Street Blacksburg, Virginia 24060 National Bankshares, Inc. Registration Statement on Form S-8 ---------------------------------- Dear Sirs: I have acted as counsel to National Bankshares, Inc., a Virginia corporation (the "Company"), in connection with the preparation and filing of a registration statement on Form S-8 under the Securities Act of 1933, as amended, with respect to 250,000 shares of the Company s Common Stock, $2.50 par value per share (the "Shares"), to be offered pursuant to the Company s 1999 Stock Option Plan (the "Plan"). In rendering this opinion, I have relied upon, among other things, my examination of the Plan and such records of the Company and certificates of its officers and of public officials as I have deemed necessary. Based upon the foregoing and the further qualifications stated below, I am of the opinion that: (1) The Company is duly incorporated, validly existing and in good standing under the laws of the Commonwealth of Virginia; and (2) The Shares have been duly authorized and, when distributed in accordance with the terms of the Plan, will be legally issued, fully paid and non-assessable. I hereby consent to the filing of this opinion with the Securities and Exchange Commission as an exhibit to such registration statement and any amendments thereto and to the use of my name under the heading "Legal Opinions" in any Prospectus for the Plan. Very truly yours, /s/ MARILYN B. BUHYOFF Marilyn B. Buhyoff Counsel National Bankshares, Inc.