The inventory cost of stocking spare parts is a nonnegligible expenditure of providing after-sales service for the manufacturers making capital-intensive products, such as electric vehicles. Especially, for warranty repair service, it is important to manage the spare stock appropriately to satisfy the warranty claims of customers as well as reduce the associated inventory costs. In this paper, we investigate the spare parts inventory issue related to a critical component for under-warranty units of a product. In particular, under the free-replacement warranty policy, failed component will be replaced by a new one by consuming the spare stock. According to the field claim data, we find that the general trend of warranty claims is nonstationary, which will be affected by the product sales and under-warranty failures. Thus, we first propose a model to forecast the time-varying warranty repair demand by explicitly considering the randomness from two major sources, that is, product sales and under-warranty failures. Under the assumptions of Poisson sales process and exponential failure distribution, the closed-form expressions of mean and variance of cumulative warranty repair demand over time are obtained. Because the number of warranty claims in each period is a one-time data, the associated distribution information is unavailable. Then, based on the properties of the demand statistics, we derived a worst-case upper bound for the associated inventory cost and formulate a three-phase finite-horizon spare parts inventory model, which can be used to appropriately address the time-varying warranty claims. Finally, numerical experiments are conducted to investigate the key parameters affecting the optimal decisions where a case study based on real data is presented.