<?xml version="1.0"?>
<ownershipDocument>

    <schemaVersion>X0609</schemaVersion>

    <documentType>4</documentType>

    <periodOfReport>2026-06-17</periodOfReport>

    <notSubjectToSection16>0</notSubjectToSection16>

    <issuer>
        <issuerCik>0001679268</issuerCik>
        <issuerName>MAMMOTH ENERGY SERVICES, INC.</issuerName>
        <issuerTradingSymbol>TUSK</issuerTradingSymbol>
        <issuerForeignTradingSymbol></issuerForeignTradingSymbol>
    </issuer>

    <reportingOwner>
        <reportingOwnerId>
            <rptOwnerCik>0001048462</rptOwnerCik>
            <rptOwnerName>WEXFORD CAPITAL LP</rptOwnerName>
        </reportingOwnerId>
        <reportingOwnerAddress>
            <rptOwnerNonUSAddressFlag>false</rptOwnerNonUSAddressFlag>
            <rptOwnerStreet1>777 SOUTH FLAGLER DRIVE</rptOwnerStreet1>
            <rptOwnerStreet2>SUITE 602 EAST</rptOwnerStreet2>
            <rptOwnerCity>WEST PALM BEACH</rptOwnerCity>
            <rptOwnerState>FL</rptOwnerState>
            <rptOwnerZipCode>33401-6122</rptOwnerZipCode>
            <rptOwnerStateDescription></rptOwnerStateDescription>
        </reportingOwnerAddress>
        <reportingOwnerRelationship>
            <isDirector>1</isDirector>
            <isOfficer>1</isOfficer>
            <isTenPercentOwner>1</isTenPercentOwner>
            <isOther>0</isOther>
            <officerTitle>Chief Business Officer</officerTitle>
            <otherText></otherText>
        </reportingOwnerRelationship>
    </reportingOwner>

    <reportingOwner>
        <reportingOwnerId>
            <rptOwnerCik>0001472112</rptOwnerCik>
            <rptOwnerName>Wexford GP LLC</rptOwnerName>
        </reportingOwnerId>
        <reportingOwnerAddress>
            <rptOwnerNonUSAddressFlag>false</rptOwnerNonUSAddressFlag>
            <rptOwnerStreet1>C/O WEXFORD CAPITAL LP</rptOwnerStreet1>
            <rptOwnerStreet2>777 SOUTH FLAGLER DRIVE, SUITE 602 EAST</rptOwnerStreet2>
            <rptOwnerCity>WEST PALM BEACH</rptOwnerCity>
            <rptOwnerState>CT</rptOwnerState>
            <rptOwnerZipCode>33401</rptOwnerZipCode>
            <rptOwnerStateDescription></rptOwnerStateDescription>
        </reportingOwnerAddress>
        <reportingOwnerRelationship>
            <isDirector>1</isDirector>
            <isOfficer>1</isOfficer>
            <isTenPercentOwner>1</isTenPercentOwner>
            <isOther>0</isOther>
            <officerTitle>Chief Business Officer</officerTitle>
            <otherText></otherText>
        </reportingOwnerRelationship>
    </reportingOwner>

    <reportingOwner>
        <reportingOwnerId>
            <rptOwnerCik>0001001391</rptOwnerCik>
            <rptOwnerName>DAVIDSON CHARLES E</rptOwnerName>
        </reportingOwnerId>
        <reportingOwnerAddress>
            <rptOwnerNonUSAddressFlag>false</rptOwnerNonUSAddressFlag>
            <rptOwnerStreet1>C/O WEXFORD CAPITAL LP</rptOwnerStreet1>
            <rptOwnerStreet2>777 SOUTH FLAGLER DRIVE, SUITE 602</rptOwnerStreet2>
            <rptOwnerCity>WEST PALM BEACH</rptOwnerCity>
            <rptOwnerState>FL</rptOwnerState>
            <rptOwnerZipCode>33401</rptOwnerZipCode>
            <rptOwnerStateDescription></rptOwnerStateDescription>
        </reportingOwnerAddress>
        <reportingOwnerRelationship>
            <isDirector>1</isDirector>
            <isOfficer>1</isOfficer>
            <isTenPercentOwner>1</isTenPercentOwner>
            <isOther>0</isOther>
            <officerTitle>Chief Business Officer</officerTitle>
            <otherText></otherText>
        </reportingOwnerRelationship>
    </reportingOwner>

    <reportingOwner>
        <reportingOwnerId>
            <rptOwnerCik>0001048485</rptOwnerCik>
            <rptOwnerName>JACOBS JOSEPH</rptOwnerName>
        </reportingOwnerId>
        <reportingOwnerAddress>
            <rptOwnerNonUSAddressFlag>false</rptOwnerNonUSAddressFlag>
            <rptOwnerStreet1>C/O WEXFORD CAPITAL LP</rptOwnerStreet1>
            <rptOwnerStreet2>777 SOUTH FLAGLER DRIVE, SUITE 602 EAST</rptOwnerStreet2>
            <rptOwnerCity>WEST PALM BEACH</rptOwnerCity>
            <rptOwnerState>FL</rptOwnerState>
            <rptOwnerZipCode>33401</rptOwnerZipCode>
            <rptOwnerStateDescription></rptOwnerStateDescription>
        </reportingOwnerAddress>
        <reportingOwnerRelationship>
            <isDirector>1</isDirector>
            <isOfficer>1</isOfficer>
            <isTenPercentOwner>1</isTenPercentOwner>
            <isOther>0</isOther>
            <officerTitle>Chief Business Officer</officerTitle>
            <otherText></otherText>
        </reportingOwnerRelationship>
    </reportingOwner>

    <aff10b5One>0</aff10b5One>

    <nonDerivativeTable>
        <nonDerivativeTransaction>
            <securityTitle>
                <value>Common Stock</value>
            </securityTitle>
            <transactionDate>
                <value>2026-06-17</value>
            </transactionDate>
            <deemedExecutionDate></deemedExecutionDate>
            <transactionCoding>
                <transactionFormType>4</transactionFormType>
                <transactionCode>J</transactionCode>
                <equitySwapInvolved>0</equitySwapInvolved>
                <footnoteId id="F1"/>
            </transactionCoding>
            <transactionTimeliness></transactionTimeliness>
            <transactionAmounts>
                <transactionShares>
                    <value>1072896</value>
                </transactionShares>
                <transactionPricePerShare>
                    <value>0</value>
                </transactionPricePerShare>
                <transactionAcquiredDisposedCode>
                    <value>A</value>
                </transactionAcquiredDisposedCode>
            </transactionAmounts>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>1451034</value>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
            </ownershipNature>
        </nonDerivativeTransaction>
        <nonDerivativeTransaction>
            <securityTitle>
                <value>Common Stock</value>
            </securityTitle>
            <transactionDate>
                <value>2026-06-17</value>
            </transactionDate>
            <deemedExecutionDate></deemedExecutionDate>
            <transactionCoding>
                <transactionFormType>4</transactionFormType>
                <transactionCode>J</transactionCode>
                <equitySwapInvolved>0</equitySwapInvolved>
                <footnoteId id="F2"/>
            </transactionCoding>
            <transactionTimeliness></transactionTimeliness>
            <transactionAmounts>
                <transactionShares>
                    <value>6354667</value>
                </transactionShares>
                <transactionPricePerShare>
                    <value>0</value>
                </transactionPricePerShare>
                <transactionAcquiredDisposedCode>
                    <value>A</value>
                </transactionAcquiredDisposedCode>
            </transactionAmounts>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>6601215</value>
                    <footnoteId id="F3"/>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>I</value>
                </directOrIndirectOwnership>
                <natureOfOwnership>
                    <value>See footnotes</value>
                    <footnoteId id="F4"/>
                    <footnoteId id="F5"/>
                </natureOfOwnership>
            </ownershipNature>
        </nonDerivativeTransaction>
        <nonDerivativeTransaction>
            <securityTitle>
                <value>Common Stock</value>
            </securityTitle>
            <transactionDate>
                <value>2026-06-17</value>
            </transactionDate>
            <deemedExecutionDate></deemedExecutionDate>
            <transactionCoding>
                <transactionFormType>4</transactionFormType>
                <transactionCode>P</transactionCode>
                <equitySwapInvolved>0</equitySwapInvolved>
            </transactionCoding>
            <transactionTimeliness></transactionTimeliness>
            <transactionAmounts>
                <transactionShares>
                    <value>4019574</value>
                </transactionShares>
                <transactionPricePerShare>
                    <value>2.6043</value>
                </transactionPricePerShare>
                <transactionAcquiredDisposedCode>
                    <value>A</value>
                </transactionAcquiredDisposedCode>
            </transactionAmounts>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>10620789</value>
                    <footnoteId id="F3"/>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>I</value>
                </directOrIndirectOwnership>
                <natureOfOwnership>
                    <value>See footnotes</value>
                    <footnoteId id="F4"/>
                    <footnoteId id="F5"/>
                </natureOfOwnership>
            </ownershipNature>
        </nonDerivativeTransaction>
    </nonDerivativeTable>

    <footnotes>
        <footnote id="F1">Represents an in-kind distribution from MEH SUB LLC (&quot;MEH SUB&quot;), an entity managed by Wexford Capital LP (&quot;Wexford Capital&quot;), as payment of fees and expenses owed to Wexford Capital related to its performance of investment management services.</footnote>
        <footnote id="F2">Represents an in-kind distribution from MEH SUB that does not involve (i) a purchase or a sale of securities or (ii) any additional consideration.</footnote>
        <footnote id="F3">Represents the common stock of the Issuer held in the aggregate by Wexford Spectrum Trading Limited (&quot;WST&quot;), Wexford Catalyst Trading Limited (&quot;WCT&quot;) and Wexford Focused Trading Limited (&quot;WFT&quot;, and together with WST and WCT, the &quot;Wexford Entities&quot;).</footnote>
        <footnote id="F4">Wexford Capital may, by reason of its status as (i) sub-advisor of each of WST and WCT and (ii) investment manager of WFT be deemed to own beneficially the securities held by the Wexford Entities. Wexford GP LLC (&quot;Wexford GP&quot;) may, as the General Partner of Wexford Capital, be deemed to own beneficially the securities held by the Wexford Entities. Each of Charles E. Davidson (&quot;Davidson&quot;) and Joseph M. Jacobs (&quot;Jacobs&quot;, and together with the Wexford Entities, Wexford Capital, Wexford GP and Davidson, the &quot;Reporting Persons&quot;) may, by reason of his status as a controlling person of Wexford GP, be deemed to own beneficially the securities held by the Wexford Entities.</footnote>
        <footnote id="F5">Each of Wexford Capital, Wexford GP, Davidson and Jacobs share the power to vote and to dispose of the securities held by the Wexford Entities. Each of Wexford Capital, Wexford GP, Davidson and Jacobs disclaim beneficial ownership of the securities held by the Wexford Entities and this report shall not be deemed as an admission that they are the beneficial owners of such securities, except to the extent of any pecuniary interests therein. The Reporting Persons may be deemed to be a director and officer of the Issuer by virtue of Paul Jacobi, an employee of Wexford Capital, serving as a director and officer of the Issuer.</footnote>
    </footnotes>

    <ownerSignature>
        <signatureName>Wexford Capital LP, By: Wexford GP LLC, its general partner, By: Mark E. Ahern, Vice President and Assistant Secretary</signatureName>
        <signatureDate>2026-06-22</signatureDate>
    </ownerSignature>

    <ownerSignature>
        <signatureName>Wexford GP LLC, By: Mark E. Ahern, Vice President and Assistant Secretary</signatureName>
        <signatureDate>2026-06-22</signatureDate>
    </ownerSignature>

    <ownerSignature>
        <signatureName>Charles E. Davidson</signatureName>
        <signatureDate>2026-06-22</signatureDate>
    </ownerSignature>

    <ownerSignature>
        <signatureName>Joseph M. Jacobs</signatureName>
        <signatureDate>2026-06-22</signatureDate>
    </ownerSignature>
</ownershipDocument>
