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

    <schemaVersion>X0206</schemaVersion>

    <documentType>3</documentType>

    <periodOfReport>2026-03-17</periodOfReport>

    <noSecuritiesOwned>0</noSecuritiesOwned>

    <issuer>
        <issuerCik>0000904851</issuerCik>
        <issuerName>YPF SOCIEDAD ANONIMA</issuerName>
        <issuerTradingSymbol>YPF</issuerTradingSymbol>
    </issuer>

    <reportingOwner>
        <reportingOwnerId>
            <rptOwnerCik>0002119760</rptOwnerCik>
            <rptOwnerName>Martin Mauricio Alejandro</rptOwnerName>
        </reportingOwnerId>
        <reportingOwnerAddress>
            <rptOwnerStreet1>MACACHA GUEMES 515</rptOwnerStreet1>
            <rptOwnerStreet2></rptOwnerStreet2>
            <rptOwnerCity>CABA</rptOwnerCity>
            <rptOwnerState>C1</rptOwnerState>
            <rptOwnerZipCode>00000</rptOwnerZipCode>
            <rptOwnerStateDescription>ARGENTINA</rptOwnerStateDescription>
        </reportingOwnerAddress>
        <reportingOwnerRelationship>
            <isDirector>1</isDirector>
            <isOfficer>1</isOfficer>
            <isTenPercentOwner>0</isTenPercentOwner>
            <isOther>0</isOther>
            <officerTitle>Midstrm. &amp; Downstrm. Exec. VP</officerTitle>
            <otherText></otherText>
        </reportingOwnerRelationship>
    </reportingOwner>

    <nonDerivativeTable>
        <nonDerivativeHolding>
            <securityTitle>
                <value>Class D Common Stock</value>
            </securityTitle>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>2144</value>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
            </ownershipNature>
        </nonDerivativeHolding>
        <nonDerivativeHolding>
            <securityTitle>
                <value>American Depositary Shares</value>
            </securityTitle>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>1320</value>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
            </ownershipNature>
        </nonDerivativeHolding>
    </nonDerivativeTable>

    <derivativeTable>
        <derivativeHolding>
            <securityTitle>
                <value>Long-Term Incentive Share Award</value>
                <footnoteId id="F1"/>
            </securityTitle>
            <conversionOrExercisePrice>
                <footnoteId id="F1"/>
            </conversionOrExercisePrice>
            <exerciseDate>
                <value>2026-01-09</value>
            </exerciseDate>
            <expirationDate>
                <footnoteId id="F1"/>
            </expirationDate>
            <underlyingSecurity>
                <underlyingSecurityTitle>
                    <value>Class D Common Stock</value>
                </underlyingSecurityTitle>
                <underlyingSecurityShares>
                    <value>15491</value>
                </underlyingSecurityShares>
            </underlyingSecurity>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
            </ownershipNature>
        </derivativeHolding>
        <derivativeHolding>
            <securityTitle>
                <value>Long-Term Incentive Share Award</value>
                <footnoteId id="F1"/>
            </securityTitle>
            <conversionOrExercisePrice>
                <footnoteId id="F1"/>
            </conversionOrExercisePrice>
            <exerciseDate>
                <value>2027-01-09</value>
            </exerciseDate>
            <expirationDate>
                <footnoteId id="F1"/>
            </expirationDate>
            <underlyingSecurity>
                <underlyingSecurityTitle>
                    <value>Class D Common Stock</value>
                </underlyingSecurityTitle>
                <underlyingSecurityShares>
                    <value>11608</value>
                </underlyingSecurityShares>
            </underlyingSecurity>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
            </ownershipNature>
        </derivativeHolding>
        <derivativeHolding>
            <securityTitle>
                <value>Long-Term Incentive Share Award</value>
                <footnoteId id="F1"/>
            </securityTitle>
            <conversionOrExercisePrice>
                <footnoteId id="F1"/>
            </conversionOrExercisePrice>
            <exerciseDate>
                <value>2028-01-09</value>
            </exerciseDate>
            <expirationDate>
                <footnoteId id="F1"/>
            </expirationDate>
            <underlyingSecurity>
                <underlyingSecurityTitle>
                    <value>Class D Common Stock</value>
                </underlyingSecurityTitle>
                <underlyingSecurityShares>
                    <value>5080</value>
                </underlyingSecurityShares>
            </underlyingSecurity>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
            </ownershipNature>
        </derivativeHolding>
    </derivativeTable>

    <footnotes>
        <footnote id="F1">Share awards are granted pursuant to YPF S.A.'s Long-Term Incentive Share Award (Programa de Retribucion a Largo Plazo). Each award unit represents the right to receive one Class D common stock of YPF S.A. (or, at the Company's discretion, one ADR) upon vesting. The awards vest in three equal installments in July 2026, 2027, and 2028, subject to continued employment through each vesting date.</footnote>
    </footnotes>

    <ownerSignature>
        <signatureName>Mauricio Alejandro Martin</signatureName>
        <signatureDate>2026-03-17</signatureDate>
    </ownerSignature>
</ownershipDocument>