Oil sludge presents a harmful but economically valuable waste. A large amount of oil sludge is produced during the processes of extraction, refining, storage, and transportation of petroleum. The contents of oil, water, and slag in the oil sludge are important parameters that determine the economic value of oil sludge and the choice of oil recovery methods. Most existing phase-content measurement methods can be applied only to the oil-water two-phase mixtures. A simple, low cost, and fast ultrasonic velocity based method is proposed in this paper. The proposed method can realize the three-phase content measurement of oil sludge in storage tanks. First, a semi-empirical model of water content in the oil-water mixture, which describes the relationship between ultrasound velocity and water content in the mixture, is derived. Next, the effect of the temperature on the ultrasound velocity is investigated. Within a certain temperature range, ultrasonic waves in water have different velocity characteristics that depend on temperature than that in oil. Then the effect of the slag on the ultrasound velocity is analyzed experimentally. Based on these effects, a three-phase content measurement method based on ultrasound velocity is proposed. A prototype of three-phase content measurement is developed and experiments are carried out to validate the proposed method. Experimental results show that the proposed method can realize the three-phase content measurement of oil sludge in the storage tank, achieving the root mean square error (RMSE) of the water content of 1.48% and the RMSE of the slag content of 0.73%.