Nvidia disclosed Friday that its stake in SpaceX was worth about $21 billion at the end of the second quarter, revealing the chipmaker as one of the largest shareholders in Elon Musk's rocket and artificial intelligence company.

The company said in a filing with the Securities and Exchange Commission that it owns 122.8 million Class A shares in SpaceX, which made its public market debut in June.

The position has since shrunk. SpaceX shares closed at $140 on Friday, down from $170.86 at the end of June, reducing the value of Nvidia's holding to roughly $17.2 billion.

Nvidia did not buy the shares on the open market. The stake traces back to January, when the chipmaker put $10 billion into Musk's xAI as part of a $20 billion funding round, according to a person familiar with the deal who spoke to CNBC on condition of anonymity because the size of the investment was not made public. SpaceX acquired xAI in February in a transaction valued at $1.25 trillion, converting Nvidia's cash into rocket-company stock.

The disclosure places SpaceX behind only Intel among Nvidia's equity holdings. The Intel position was worth about $30 billion at the close of the quarter and has since narrowed to roughly $22 billion following a secondary offering. Together, the two companies account for close to 80% of Nvidia's publicly disclosed stock portfolio.

Both are also customers that have committed to Nvidia's chips. Musk said on SpaceX's second-quarter earnings call this month that the company will use Nvidia processors exclusively in its AI data centers, describing the company's graphics processing units as having the best architecture for training and running AI models. He added that he expects SpaceX to receive a significant allocation of Nvidia's forthcoming Vera Rubin chips next year.

The concentration has drawn scrutiny from analysts, who note that Nvidia now carries exposure to the same companies on both sides of its ledger. Should SpaceX or Intel falter, Nvidia would absorb the impact twice, once as a supplier whose orders shrink and again as an investor whose holdings lose value.

Nvidia ranks sixth among SpaceX shareholders, according to FactSet data. Musk holds the largest position by a wide margin, valued at roughly $850 billion, followed by Alphabet at about $78 billion.