Let \(\Omega\subset\mathbb{R}^n\) be an open, connected subset of \(\mathbb{R}^n\), and let \(F\colon\Omega-\Omega\to\mathbb{C}\), where \(\Omega-\Omega=\{x-y\colon x,y\in\Omega\}\), be a continuous positive definite function. We give necessary and sufficient conditions for \(F\) to have an extension to a continuous positive definite function defined on the entire Euclidean space \(\mathbb{R}^n\). The conditions are formulated in terms of strong commutativity of a system of certain unbounded selfadjoint operators defined on a Hilbert space associated to \(F\). When a positive definite function \(F\) is extendable, we show that it is characterized by existence of associated unitary representations of \(\mathbb{R}^n\). Different positive definite extensions correspond to different unitary representations. We prove that each such unitary representation has simple spectrum. We give necessary and sufficient conditions for a continuous positive definite function to have exactly one extension. Our proof regarding extensions of positive definite functions carries over mutatis mutandis to the case of conditionally negative definite functions, which has applications to Gaussian stochastic processes, whose increments in mean-square are stationary (e.g., fractional Brownian motion).