EX-5.1 3 a2140932zex-5_1.htm EX-5.1
QuickLinks -- Click here to rapidly navigate through this document


Exhibit 5.1

July 26, 2004

RLI Corp.
9025 North Lindbergh Drive
Peoria, Illinois 61615

      Re:
      RLI Corp. Registration Statement on Form S-8

Ladies and Gentlemen:

        We have acted as special counsel to RLI Corp. (the "Company") in connection with the proposed registration by the Company of 200,000 shares of the Company's Common Stock, par value $1 per share (the "Common Stock"), which are issuable under the RLI Corp. Nonemployee Directors' Stock Plan (the "Plan"), pursuant to a Registration Statement on Form S-8 filed with the Securities and Exchange Commission (the "Commission") under the Securities Act of 1933, as amended (the "Act") (such Registration Statement, as amended or supplemented, is hereinafter referred to as the "Registration Statement").

        The opinions contained in this letter (herein called "our opinion") are based exclusively upon the Business Corporation Act of 1983 of the State of Illinois, as now constituted. We express no opinion as to the applicability of, compliance with, or effect of any other law or governmental requirement with respect to the Company. For purposes of our opinions we have assumed without independent investigation that factual information supplied to us for purposes of our opinions is complete and accurate.

        Based upon and subject to the foregoing, we hereby advise you that in our opinion:

        (1)   The Company is a corporation existing and in good standing under the laws of the State of Illinois.

        (2)   Each share of Common Stock registered under the Registration Statement and issuable under the Plan, when issued as authorized by the Company upon payment of the consideration to be paid therefor pursuant to the Plan, will be validly issued, fully paid and non-assessable.

        For purposes of this letter we have relied upon (i) information contained in one or more certificates provided by the Illinois Secretary of State and (ii) factual information supplied to us by the Company. We have assumed without investigation that there has been no relevant change or development between the dates as of which the information cited in the preceding sentence was given and the date of this letter and that the information upon which we have relied is accurate and does not omit disclosures necessary to prevent such information from being misleading. For purposes of each opinion in paragraph 1, we have relied exclusively upon a certificate issued by the Illinois Secretary of State, and such opinion is not intended to provide any conclusion or assurance beyond that conveyed by that certificate.

        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 in the Registration Statement. In giving this consent, we do not thereby admit that we are in the category of persons whose consent is required under Section 7 of the Act or the rules and regulations of the Commission thereunder.

        We do not find it necessary for the purposes of this opinion, and accordingly we do not purport to cover herein, the application of the securities or "Blue Sky" laws of the various states to the issuance and sale of each share of Common Stock registered under the Registration Statement.

        This opinion is limited to the specific issues addressed herein, and no opinion may be inferred or implied beyond that expressly stated herein. We assume no obligation to revise or supplement this opinion should the present laws of the State of Illinois be changed by legislative action, judicial decision or otherwise.

Sincerely,

/s/ Katten Muchin Zavis Rosenman




QuickLinks