EXHIBIT 5 March 16, 1998 Juniata Valley Financial Corp. Bridge and Main Streets Mifflintown, PA 17059 Re: Juniata Valley Financial Corp. Registration Statement on Form S-4 Gentlemen: We have acted as counsel to Juniata Valley Financial Corp., a Pennsylvania corporation (the "Company"), in connection with the preparation of a registration statement on Form S-4, as amended (the "Registration Statement") filed with the Securities and Exchange Commission under the Securities Act of 1933, as amended (the "Act"), relating to the public offering of up to 937,024 shares of the Company's common stock, par value $1.00 per share (the "Common Stock"). The Company will offer such shares in connection with the merger (the "Merger") provided for in that Agreement and Plan of Reorganization dated December 30, 1997 among the Company, Juniata Valley Bank, and Lewistown Trust Company (the "Agreement"). In this connection we have reviewed (a) the Registration Statement, (b) the Company's Articles of Incorporation and By-laws, (c) a copy of the Agreement, and (d) certain records of the Company's corporate proceedings. In our examination, we have assumed the genuineness of all signatures, the authenticity of all documents submitted to us as originals and the conformity with the original of all documents submitted to us as copies thereof. Our opinion set forth below is limited to the Pennsylvania Business Corporation Law of 1988, as amended. In our opinion, the shares of Common Stock to be issued by the Company in connection with the Merger, when issued by the Company in connection with the Merger pursuant to the Agreement, will be legally issued, fully paid and non- assessable. We hereby consent to the use of this opinion as Exhibit 5 to the Registration Statement. In giving such opinion, we do not thereby admit that we are acting within the category of persons whose consent is required under Section 7 of the Act or the rules or regulations of the Securities and Exchange Commission thereunder. Very truly yours, /s/ James A. Ulsh JAU:mk