Abstract. We determine the Galois representations inside the -adic cohomology of some quaternionic and related unitary Shimura varieties at ramified places. The main results generalize the previous works of Reimann and Kottwitz in this setting to arbitrary levels at p, and confirm the expected description of the cohomology due to Langlands and Kottwitz.