Morphology and crystalline-phase control of titanium dioxide is a crucial issue in the study of photocatalytic activity. Here, we present a facile synthetic path combing the sol–gel method with solvothermal treatment to form hybrid mesoporous and microporous TiO2. The TiO2 precursor was obtained by the sol–gel method, and this was self-assembled into mesopores and micropores by NH4F corrosiveness on the surface of TiO2 under hydrothermal conditions. Powder X-ray diffraction (XRD), thermogravimetric analysis and differential scanning calorimetry (TGA/DSC), X-ray photoelectron spectroscopy (XPS), N2 adsorption measurements, transmission electron microscopy (TEM) and Raman spectroscopy were used to characterise the titania powders. The results reveal that NH4F not only improved the formation of the crystallised anatase phase but also served as a corrosive agent modified on the surface of TiO2 precursors. Defective voids among these nanoparticles formed micropores by hydrothermal reaction of NH4F and TiO2 over a long time. When the NH4F concentration was 1.0 mol L−1, micropores became dominant,and few mesopores were obtained, and this results in a smaller average pore size. Thus, mesoporous and microporous structures were formed. Furthermore, these crystallised mesoporous and microporous anatase titania nanoparticles with uniform structure and high surface area have a higher photocatalytic activity for azo dye degradation under near UV irradiation.