EXHIBIT NO. 99.(j) 4

CONSENT OF INDEPENDENT REGISTERED PUBLIC ACCOUNTING FIRM

We consent to the incorporation by reference in this Post-Effective Amendment to Registration Statement No. 2-74959 on Form N-1A of our report dated April 15, 2026, relating to the financial statements and financial highlights of MFS Government Securities Fund, appearing in Form N-CSR of MFS Series Trust XIII for the year ended February 28, 2026, and to the references to us under the headings “Financial Highlights” in the Prospectus and “Independent Registered Public Accounting Firm(s) and Financial Statements” and Appendix M – "Recipients of Non-Public Portfolio Holdings on an Ongoing Basis" in the Statement of Additional Information, which are part of such Registration Statement.

/s/DELOITTE & TOUCHE LLP 

Deloitte & Touche LLP

Boston, Massachusetts

June 24, 2026