Background: Ketoconazole (KZ) is categorized as class II according to the Biopharmaceutics Classification System (BSC) classification, which shows a strong pH-dependent solubility where its solubility is enhanced under an acidic medium (pH below 3). This strong pH dependence results in unpredictable absorption and a wide range of bioavailabilities. Objective: To prolong the gastric residence time of KZ’s tablet to enhance KZ’s solubility and hence its bioavailability for better therapeutic activity. Methods: To prepare mucoadhesive tablets, we use both direct and wet granulation methods. We employed various evaluation tests to assess the prepared tablets. These tests encompass a range of assessments, including weight variation, hardness, thickness, friability, disintegration test, swelling study, mucoadhesive strength study, and in vitro drug release studies. Results: The study found that polymer viscosity, as well as polymer concentration, have a significant effect on mucoadhesive strength and drug release, whereas diluent type has a non-significant influence on drug release. We selected Formula 7, which employs xanthan gum as a mucoadhesive polymer in a 1:1 drug polymer ratio, as the optimum formula because it provides an accepted physico-mechanical property and releases 87% of the drug over 8 hours. Conclusions: Gastric mucoadhesive tablets may be an effective method of delivering active ingredients, as they provide a favorable environment that enhances their dissolution by extending their duration in the stomach, thereby increasing their bioavailability.