Metallic osmium (Os) is one of the most exceptional elemental materials, having, at ambient pressure, the highest known density and one of the highest cohesive energies and melting temperatures. It is also very incompressible, but its high-pressure behaviour is not well understood because it has been studied so far only at pressures below 75 gigapascals. Here we report powder X-ray diffraction measurements on Os at multi-megabar pressures using both conventional and double-stage diamond anvil cells, with accurate pressure determination ensured by first obtaining self-consistent equations of state of gold, platinum, and tungsten in static experiments up to 500 gigapascals. These measurements allow us to show that Os retains its hexagonal close-packed structure upon compression to over 770 gigapascals. But although its molar volume monotonically decreases with pressure, the unit cell parameter ratio of Os exhibits anomalies at approximately 150 gigapascals and 440 gigapascals. Dynamical mean-field theory calculations suggest that the former anomaly is a signature of the topological change of the Fermi surface for valence electrons. However, the anomaly at 440 gigapascals might be related to an electronic transition associated with pressure-induced interactions between core electrons. The ability to affect the core electrons under static high-pressure experimental conditions, even for incompressible metals such as Os, opens up opportunities to search for new states of matter under extreme compression.