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

    <schemaVersion>X0508</schemaVersion>

    <documentType>4</documentType>

    <periodOfReport>2026-02-23</periodOfReport>

    <issuer>
        <issuerCik>0000836147</issuerCik>
        <issuerName>MIDDLEFIELD BANC CORP</issuerName>
        <issuerTradingSymbol>MBCN</issuerTradingSymbol>
    </issuer>

    <reportingOwner>
        <reportingOwnerId>
            <rptOwnerCik>0001968970</rptOwnerCik>
            <rptOwnerName>Moeller Jennifer L</rptOwnerName>
        </reportingOwnerId>
        <reportingOwnerAddress>
            <rptOwnerStreet1>15985 EAST HIGH STREET</rptOwnerStreet1>
            <rptOwnerStreet2></rptOwnerStreet2>
            <rptOwnerCity>MIDDLEFIELD</rptOwnerCity>
            <rptOwnerState>OH</rptOwnerState>
            <rptOwnerZipCode>44062</rptOwnerZipCode>
            <rptOwnerStateDescription></rptOwnerStateDescription>
        </reportingOwnerAddress>
        <reportingOwnerRelationship>
            <isDirector>1</isDirector>
        </reportingOwnerRelationship>
    </reportingOwner>

    <aff10b5One>0</aff10b5One>

    <nonDerivativeTable>
        <nonDerivativeTransaction>
            <securityTitle>
                <value>Common Stock</value>
            </securityTitle>
            <transactionDate>
                <value>2026-02-23</value>
            </transactionDate>
            <transactionCoding>
                <transactionFormType>4</transactionFormType>
                <transactionCode>A</transactionCode>
                <equitySwapInvolved>0</equitySwapInvolved>
                <footnoteId id="F1"/>
            </transactionCoding>
            <transactionAmounts>
                <transactionShares>
                    <value>405</value>
                </transactionShares>
                <transactionPricePerShare>
                    <value>35.18</value>
                </transactionPricePerShare>
                <transactionAcquiredDisposedCode>
                    <value>A</value>
                </transactionAcquiredDisposedCode>
            </transactionAmounts>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>2482.4481</value>
                    <footnoteId id="F2"/>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
            </ownershipNature>
        </nonDerivativeTransaction>
        <nonDerivativeHolding>
            <securityTitle>
                <value>Common Stock</value>
            </securityTitle>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>2213.7633</value>
                    <footnoteId id="F2"/>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
            </ownershipNature>
        </nonDerivativeHolding>
    </nonDerivativeTable>

    <footnotes>
        <footnote id="F1">The shares represent accelerated vesting of restricted stock units (RSUs) granted on June 27, 2025.  On February 23, 2026, the Compensation Committee of Middlefield's Board of Directors approved the full vesting of all outstanding plan share awards, including the RSUs. For further information regarding the acceleration of the RSUs, please see the Form 8-K Current Report filed by Middlefield with the SEC on February 25, 2026.</footnote>
        <footnote id="F2">Includes shares acquired under MBCN Dividend Reinvestment Plan</footnote>
    </footnotes>

    <ownerSignature>
        <signatureName>/s/ Jennifer L. Moeller by Julie E. Shaw Power of Attorney</signatureName>
        <signatureDate>2026-02-25</signatureDate>
    </ownerSignature>
</ownershipDocument>
