The Japanese Hayabusa2 mission has revealed in detail the physical characteristics of the C-type asteroid 162173 Ryugu, in particular, its spinning top-shaped rubble pile structure [1] and the potentially extremely high organic content [2,3]. A widely-accepted formation scenario for Ryugu is catastrophic collision between larger asteroids and the subsequent slow gravitational accumulation of collisional debris [4,5]. However, the collisional re-accumulation scenario does not explain the origin of the abundant organic matter. An alternative scenario is that Ryugu is an extinct comet, which lost its icy components [2,6,3]. Here, the sublimation of water ice from a uniform porous cometary nucleus was numerically simulated until the refractory components, such as silicate rocks and organic matter were left behind as evaporative residues. Such a process represents the transformation from a comet to an asteroid. The spin-up related to the shrinking nucleus, associated with the water ice sublimation, was also calculated. The result of the calculation indicates that the cometary origin scenario can quantitatively account for all the features of Ryugu discussed above. We conclude that organic-rich spinning top-shaped rubble pile asteroids, such as Ryugu, are comet-asteroid transition objects or extinct comets.