This paper reports on the study of a laser-generated cavitation bubble in water collapsing near a rigid wall that is covered with a layer of silicone oil. The oil viscosity is between 5 and 5000 cSt. It is known that a collapsing cavitation bubble near a rigid boundary develops a jet. In this study, we show that the viscous oil layer competes with the flow generated by the bubble, and affects the short- and long-term bubble dynamics. For very low viscosity silicone oil (5, 10 and 20 cSt) the vortices formed when the water jet hits the wall result in a gas–water mixture in the oil layer. With increasing viscosity, i.e. 50 and 100 cSt, the formation of water droplets with gas bubbles inside the oil layer is observed. The bubble dynamics and flow in the oil layer are nicely reproduced with VoF simulations up to the second bubble collapse. In higher viscosity silicone oils (350, 500 and 1000 cSt), the water jet typically retracts completely during the re-expansion of the bubble. When a very high viscosity oil (5000 cSt) is used, a ‘mushroom’-shaped bubble is formed in water which splits in two as it collapses. To separate the regimes, we introduce a non-dimensional stress ratio relating the inertia and viscosity. This inverse Reynolds number Π becomes approximately 1 in the jet retraction regime. When Π≥ 1.0, the jet impact and vortices are effectively hindered on the rigid wall.