[LETTERHEAD OF TOBIN & TOBIN] EXHIBIT 5.1 January 30, 1998 Board of Directors Headlands Mortgage Company 1100 Larkspur Landing Circle Suite 101 Larkspur, California 94939 Re: Registration Statement on Form S-1 ---------------------------------- Ladies and Gentlemen: We have acted as your counsel in connection with the public offering by Headlands Mortgage Company, a California corporation (the "Company"), and certain selling stockholders of the Company(the "Selling Stockholders"), of an aggregate of up to 9,200,000 shares (the "Shares") of the Company's common stock, no par value (the "Common Stock"). This opinion is delivered in accordance with the requirements of Item 601(b)(5) of Regulation S-K under the Securities Act of 1933 (the "Securities Act"). In connection with this opinion, we have examined and are familiar with originals or copies, certified or otherwise identified to our satisfaction, of (i) the Registration Statement on Form S-1, relating to the Shares, filed with the Securities and Exchange Commission (the "Commission") under the Securities Act on October 20, 1997 (together with all exhibits and amendments thereto, the "Registration Statement"), (ii) the Articles of Incorporation, as amended, of the Company, (iii) the Bylaws, as amended, of the Company, (iv) a specimen of the certificate used to represent the Common Stock and (v) resolutions of the Board of Directors of the Company relating to the issuance and sale of the Shares and filing of the Registration Statement (the "Resolutions"). We have also examined such other documents, certificates and records as we have deemed necessary or appropriate as a basis for the opinion set forth below. In our examination, we have assumed the legal capacity of all natural persons, the genuineness of all signatures, the authenticity of all documents submitted to us as originals, the conformity to original documents of all documents submitted to us as certified, conformed or photostatic copies, and the authenticity of the originals of such copies. As to any facts material to this opinion which we did not independently establish or verify, we have relied upon oral or TOBIN & TOBIN Board of Directors Headlands Mortgage Company January 30, 1997 Page 2 written statements and representations of officers and other representatives of the Company and others. Members of our firm are admitted to the practice of law in the State of California and we do not express any opinion as to the laws of any other jurisdiction. Based upon and subject to the foregoing, we are of the opinion that the Shares have been duly authorized by the Company and are (or in the case of the Shares to be offered and sold by the Company, when issued and delivered in accordance with the Resolutions and against payment therefor, will be) validly issued, fully paid and nonassessable. We hereby consent to the filing of this opinion with the Commission as Exhibit 5.1 to the Registration Statement. We also consent to the reference to our firm under the heading "Legal Matters" in the Registration Statement. In giving such consent, we do not thereby admit that we are in the category of persons whose consent is required under Section 7 of the Securities Act. Very truly yours, /s/ Tobin & Tobin