I formulate geosteering as a probabilistic inverse problem: Given a sequence of log and directional survey measurements along a wellbore, and a pilot well log representing the geologic column at a known position, what are the most likely spatial positions of those surveys, and how does the geologic structure vary laterally? Constraining the problem to two dimensions, I define discrete random variables over the wellbore positions, the well log, and the geologic structure. Incorporating conditional relations among the variables, I arrange the variables in a Bayesian network. After applying geologic and instrument prior information, and evidence in the form of log and directional survey measurements, probability calculus determines the posterior joint marginal probability distributions for the well path and geologic structure. Naïvely performing the necessary multiplications and marginalizations would require impossible amounts of computer memory. Using variable elimination, I order the computations so as to reduce memory requirements, making it practical to execute on modern, commodity computers. From the posterior joint marginal, I extract the most likely well path and geologic structure and characterize confidence in these measures by posterior marginal probabilities for each variable. The Bayesian network approach enables us to solve inverse problems, like this one, spanning different physical dimensions, having nonnormal uncertainties, and having no direct forward-modeling formula.