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

    <schemaVersion>X0508</schemaVersion>

    <documentType>4</documentType>

    <periodOfReport>2024-03-11</periodOfReport>

    <issuer>
        <issuerCik>0001515673</issuerCik>
        <issuerName>Ultragenyx Pharmaceutical Inc.</issuerName>
        <issuerTradingSymbol>RARE</issuerTradingSymbol>
    </issuer>

    <reportingOwner>
        <reportingOwnerId>
            <rptOwnerCik>0001303811</rptOwnerCik>
            <rptOwnerName>Kassberg Thomas Richard</rptOwnerName>
        </reportingOwnerId>
        <reportingOwnerAddress>
            <rptOwnerStreet1>C/O ULTRAGENYX PHARMACEUTICAL INC.</rptOwnerStreet1>
            <rptOwnerStreet2>60 LEVERONI COURT</rptOwnerStreet2>
            <rptOwnerCity>NOVATO</rptOwnerCity>
            <rptOwnerState>CA</rptOwnerState>
            <rptOwnerZipCode>94949</rptOwnerZipCode>
            <rptOwnerStateDescription></rptOwnerStateDescription>
        </reportingOwnerAddress>
        <reportingOwnerRelationship>
            <isDirector>false</isDirector>
            <isOfficer>true</isOfficer>
            <isTenPercentOwner>false</isTenPercentOwner>
            <isOther>false</isOther>
            <officerTitle>CBO &amp; EVP</officerTitle>
        </reportingOwnerRelationship>
    </reportingOwner>

    <aff10b5One>false</aff10b5One>

    <nonDerivativeTable>
        <nonDerivativeTransaction>
            <securityTitle>
                <value>Common Stock</value>
            </securityTitle>
            <transactionDate>
                <value>2024-03-11</value>
            </transactionDate>
            <transactionCoding>
                <transactionFormType>4</transactionFormType>
                <transactionCode>S</transactionCode>
                <equitySwapInvolved>false</equitySwapInvolved>
            </transactionCoding>
            <transactionAmounts>
                <transactionShares>
                    <value>11509</value>
                </transactionShares>
                <transactionPricePerShare>
                    <value>49.93</value>
                    <footnoteId id="F1"/>
                </transactionPricePerShare>
                <transactionAcquiredDisposedCode>
                    <value>D</value>
                </transactionAcquiredDisposedCode>
            </transactionAmounts>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>252823</value>
                    <footnoteId id="F2"/>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
            </ownershipNature>
        </nonDerivativeTransaction>
    </nonDerivativeTable>

    <footnotes>
        <footnote id="F1">The price reported in Column 4 is a weighted average price. These shares were sold in multiple transactions at prices ranging from $49.92 to $50.06 inclusive. The Reporting Person undertakes to provide to the Issuer, any security holder of the Issuer, or the staff of the Securities and Exchange Commission, upon request, full information regarding the number of shares sold at each separate price within the range.</footnote>
        <footnote id="F2">Includes previously reported shares of common stock underlying RSUs granted to the Reporting Person, which are subject to certain vesting conditions.</footnote>
    </footnotes>

    <ownerSignature>
        <signatureName>/s/ Karah Parschauer, attorney-in-fact</signatureName>
        <signatureDate>2024-03-12</signatureDate>
    </ownerSignature>
</ownershipDocument>
