We fully characterize the optimal time paths of production and water usage by an agricultural and an oil sector that share a limited water resource. We show that for any given water stock, if the oil stock is sufficiently large, it will become optimal to have a phase during which the agricultural sector is inactive, followed by a phase during which both sectors are active again. The agricultural sector will always be active in the end as the oil stock is depleted. If agriculture is not constrained by the given natural inflow of water, then oil extraction will always end with a phase during which oil production follows a pure Hotelling path. Otherwise, oil production never follows a pure Hotelling path, because its full marginal cost must always reflect not only the imputed rent on the finite oil stock, but also the positive opportunity cost of water usage. The case of oil and agriculture sharing a water resource is but one example. Our analysis provides a framework to generalize the Hotelling rule to other cases where the full marginal opportunity cost of extracting a nonrenewable resource depends on the endogenous activity of some other sector of the economy.