The Lower Cretaceous Zubair Formation is a regionally extended gas-and oil-producing sandstone sequence in Southern Iraq. Due to the weak nature of the Zubair Formation, the lack of wellbore stability is one of the most critical challenges that continuously appears during the drilling development operations. Problems associated with lack of wellbore stability, such as the tight hole, shale caving, stuck pipe, and sidetracking, are both time-consuming and expensive. This study aimed to construct a geotechnical model based on offset well data, including rock mechanical properties, in situ stresses, and formation pore pressure, coupled with suitable rock failure criteria. Mohr-Coulomb and Mogi-Coulomb failure criteria were used to predict the potential rock failure around the wellbore. The effect of the inclination and azimuth of the deviated wells on the shear failure and tensile failure mud weights was investigated to optimize the wellbore trajectory. The results show that the best orientation to drill highly deviated wells (i. e., inclinations higher than 60 deg) is along to the minimum horizontal stress (140 deg). The recommended mud weight for this selected well trajectory ranges from 1.45 to 1.5 g/cc. This study emphasizes that a wellbore stability analysis can be applied as a cost-effective tool to guide future highly deviated boreholes for better drilling performance by reducing the nonproductive time.