Graphic

1900 K Street, NW
Washington, DC 20006-1110

+1 202 261 3300 Main

+1 202 261 3333 Fax

www.dechert.com

Exhibit 5.1

September 30, 2021

Main Street Capital Corporation

1300 Post Oak Boulevard, Suite 800

Houston, TX 77056

Ladies and Gentlemen:

We have acted as counsel to Main Street Capital Corporation, a Maryland corporation (the “Company”), in connection with the preparation and filing of a registration statement on Form N-2 (File No. 333-231146) (as amended as of the date hereof, the “Registration Statement”) filed by the Company with the Securities and Exchange Commission (the “Commission”) under the Securities Act of 1933, as amended (the “Securities Act”), which initially became effective on April 30, 2019, and the final prospectus supplement, dated September 28, 2021 (including the base prospectus filed therewith, the “Prospectus”), filed with the Commission on September 30, 2021 pursuant to Rule 424 under the Securities Act, relating to the proposed issuance by the Company of $200,000,000 aggregate principal amount of 3.000% notes due 2026 (the “Notes”), to be sold to underwriters pursuant to an underwriting agreement substantially in the form filed as Exhibit 1.1 to the Company’s Current Report on Form 8-K filed with the Commission on September 30, 2021 (the “Underwriting Agreement”). All of the Notes are to be sold by the Company as described in the Registration Statement and related Prospectus. This opinion letter is being furnished to the Company in accordance with the requirements of Item 25 of Form N-2 under the Securities Act, and we express no opinion herein as to any matter other than as to the legality of the Notes.

The Notes will be issued pursuant to the indenture, filed as an exhibit to the Registration Statement, entered into between the Company and The Bank of New York Mellon Trust Company, N.A., as trustee (the “Trustee”), on April 2, 2013, as supplemented by a fifth supplemental indenture, filed as Exhibit 4.1 to the Company’s Current Report on Form 8-K filed with the Commission on January 14, 2021, entered into between the Company and the Trustee (collectively, the “Indenture”).

As counsel to the Company, we have participated in the preparation of the Registration Statement and the Prospectus and have examined the originals or copies of the following:

(i)The Articles of Amendment and Restatement of the Company, certified as of the date hereof by an officer of the Company;
(ii)The Amended and Restated Bylaws of the Company, certified as of the date hereof by an officer of the Company;
(iii)A Certificate of Good Standing with respect to the Company issued by the State Department of Assessments and Taxation of the State of Maryland as of a recent date;


Graphic

Main Street Capital Corporation

September 30, 2021

Page 2

(iv)The resolutions of the board of directors of the Company relating to, among other things, (a) the authorization and approval of the preparation and filing of the Registration Statement, (b) the authorization, execution and delivery of the Indenture; and (c) the authorization, issuance and sale of the Notes, certified as of the date hereof by an officer of the Company;
(v)The Underwriting Agreement;
(vi)The Indenture; and
(vii)A specimen copy of the form of the Notes to be issued pursuant to the Indenture in the form attached to the Indenture.

With respect to such examination and our opinion expressed herein, we have assumed, without any independent investigation or verification, (i) the genuineness of all signatures on all documents submitted to us for examination, (ii) the legal capacity of all natural persons, (iii) the authenticity of all documents submitted to us as originals, (iv) the conformity to original documents of all documents submitted to us as conformed or reproduced copies and the authenticity of the originals of such copied documents, (v) that all certificates issued by public officials have been properly issued, (vi) that the Indenture is a valid and legally binding obligation of the parties thereto (other than the Company), and (vii) the accuracy and completeness of all corporate records made available to us by the Company. We also have assumed without independent investigation or verification the accuracy and completeness of all corporate records made available to us by the Company.

As to certain matters of fact relevant to the opinions in this opinion letter, we have relied up certificates and/or representations of officers of the Company. We have also relied on certificates and confirmations of public officials. We have not independently established the facts, or in the case of certificates or confirmations of public officials, the other statements, so relied upon.

This opinion letter is limited to the contract laws of the State of New York, as in effect on the date hereof, and we express no opinion with respect to any other laws of such jurisdiction or the laws of any other jurisdictions. Without limiting the preceding sentence, we express no opinion as to any state securities or broker dealer laws or regulations thereunder relating to the offer, issuance and sale of the Notes. This opinion letter has been prepared, and should be interpreted, in accordance with customary practice followed in the preparation of opinion letters by lawyers who regularly give, and such customary practice followed by lawyers who on behalf of their clients regularly advise opinion recipients regarding, opinion letters of this kind.

Based upon and subject to the limitations, exceptions, qualifications and assumptions set forth in this opinion letter, we are of the opinion that, when the Notes are duly executed and delivered by duly authorized officers of the Company and duly authenticated by the Trustee, all in accordance with the provisions of the Indenture, and delivered to the underwriters against payment therefor in accordance with the terms of the Underwriting Agreement, the Notes will constitute valid and legally binding obligations of the Company, enforceable against the Company in accordance with their terms, except as such enforceability may be limited by applicable bankruptcy, insolvency, reorganization, receivership, moratorium, fraudulent conveyance, and other similar laws affecting the rights and remedies of creditors generally and to general principles of equity (including without limitation the availability of specific


Graphic

Main Street Capital Corporation

September 30, 2021

Page 3

performance or injunctive relief and the application of concepts of materiality, reasonableness, good faith and fair dealing), regardless of whether considered in a proceeding at law or in equity.

The opinions expressed in this opinion letter (a) are strictly limited to the matters stated in this opinion letter, and without limiting the foregoing, no other opinions are to be implied and (b) are only as of the date of this opinion letter, and we are under no obligation, and do not undertake, to advise the Company or any other person or entity either of any change of law or fact that occurs, or of any fact that comes to our attention, after the date of this opinion letter, even though such change or such fact may affect the legal analysis or a legal conclusion in this opinion letter.

We hereby consent to the filing of this opinion as an exhibit to the Company’s Current Report on Form 8-K filed with the Commission September 30, 2021 and to the reference to our firm in the “Legal Matters” section in the Prospectus. We do not admit by giving this consent that we are in the category of persons whose consent is required under Section 7 of the Securities Act or the rules and regulations of the Commission thereunder.

Very truly yours,

/s/ Dechert LLP