The presence of a capillary bridge between solid surfaces is ubiquitous under ambient conditions. Usually, it leads to a continuous decrease of friction as a function of bridge height. Here, using molecular dynamics we show that for a capillary bridge with a small radius confined between two hydrophilic elastic solid surfaces, the friction oscillates greatly when decreasing the bridge height. The underlying mechanism is revealed to be a periodic ordered-disordered transition at the liquid-solid interfaces. This transition is caused by the balance between the surface tension of the liquid-vapor interface and the elasticity of the surface. This balance introduces a critical size below which the friction oscillates. Based on the mechanism revealed, a parameter-free analytical model for the oscillating friction was derived and found to be in excellent agreement with the simulation results. Our results describe an interesting frictional phenomenon at the nanoscale, which is most prominent for layered materials.