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

    <schemaVersion>X0607</schemaVersion>

    <documentType>3</documentType>

    <periodOfReport>2026-09-01</periodOfReport>

    <noSecuritiesOwned>0</noSecuritiesOwned>

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

    <reportingOwner>
        <reportingOwnerId>
            <rptOwnerCik>0002151766</rptOwnerCik>
            <rptOwnerName>Santilli Diego Cesar</rptOwnerName>
        </reportingOwnerId>
        <reportingOwnerAddress>
            <rptOwnerNonUSAddressFlag>true</rptOwnerNonUSAddressFlag>
            <rptOwnerStreet1>MACACHA GUEMES 515</rptOwnerStreet1>
            <rptOwnerStreet2></rptOwnerStreet2>
            <rptOwnerCity>BUENOS AIRES</rptOwnerCity>
            <rptOwnerNonUSStateTerritory></rptOwnerNonUSStateTerritory>
            <rptOwnerCountry>C1</rptOwnerCountry>
            <rptOwnerZipCode>00000</rptOwnerZipCode>
            <rptOwnerStateDescription>ARGENTINA</rptOwnerStateDescription>
        </reportingOwnerAddress>
        <reportingOwnerRelationship>
            <isDirector>1</isDirector>
            <isOfficer>0</isOfficer>
            <isTenPercentOwner>0</isTenPercentOwner>
            <isOther>0</isOther>
            <officerTitle></officerTitle>
            <otherText></otherText>
        </reportingOwnerRelationship>
    </reportingOwner>

    <nonDerivativeTable>
        <nonDerivativeHolding>
            <securityTitle>
                <value>Class D Common Stock</value>
            </securityTitle>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>9010</value>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>I</value>
                </directOrIndirectOwnership>
                <natureOfOwnership>
                    <value>By a Corporation</value>
                    <footnoteId id="F1"/>
                </natureOfOwnership>
            </ownershipNature>
        </nonDerivativeHolding>
    </nonDerivativeTable>

    <footnotes>
        <footnote id="F1">The reporting person expressly disclaims beneficial ownership of these shares, except to the extent of her pecuniary interest therein.</footnote>
    </footnotes>

    <ownerSignature>
        <signatureName>/s/ DIEGO CESAR SANTILLI</signatureName>
        <signatureDate>2026-09-01</signatureDate>
    </ownerSignature>
</ownershipDocument>
