The oxygen order in YBa2Cu3O6+x has been investigated by Monte Carlo simulation with the two-dimensional anisotropic next-nearest-neighbor lattice gas model, the ASYNNNI model. For a specific set of interaction parameters we have calculated the structural phase diagram, the chemical potential, and the structure factor as a function of temperature and wave vector for x = 0.4. The phase diagram has been determined from an ivestigation of the order parameters and their fluctuations as well as by the use of an improved version of the Ferrenberg-Swendsen method. The calculated phase diagram and the widths of the structure factors are in excellent agreement with measured neutron-diffraction data. We suggest that the observation of an orthorhombic distortion, simultaneously with only short-range oxygen order at T = 25-degrees-C, is due to the freezing-in of an ortho-II domain state with a preferred oxygen chain direction and accordingly only two types of domains. Using thermodynamic relations the chemical potential has been related to the measured oxygen-gas pressure, and it is discussed why only qualitative agreement with experimental data is established.