The study’s goal was to create an intrarectal mucoadhesive gel of sumatriptan (SMT) combining mucoadhesive polymer (xyloglucan) and thermosensitive polymers (poloxamer 407 and poloxamer 188) to prolong rectal residence time for treatment of migraines. Nine SMT mucoadhesive rectal gel (RIG) formulas were created by mixing poloxamer 407 (18%, 19%, or 20%) with poloxamer 188 (5%), a mucoadhesive polymer at various doses (0.1, 0.2, and 0.3) as well as SMT (25 mg/ml). The prepared suppositories underwent for mucoadhesive force, gelation temperature, and gelation time. When SMT and mucoadhesive polymer were added to the poloxamer mixture, the gelation temperature dropped; however, poloxamer 188 had the opposite effect. These polymers supported the prepared liquids’ ability to adhere to mucous membranes and form a strong gel. The transition gelation temperature of the poloxamer solution rose as a result of the addition of poloxamer 188. The findings showed that the formula RIG5 which is composed of poloxamer 407 (19%), poloxamer 188 (5%), and xyloglucan (0.2%) had an ideal transition temperature of 36.33°C, gel strength of 44.66°C, mucoadhesive force of 6409°C, and drug release of 93.98% over an 8-hour period. In light of this, it can be said that SMT was successfully manufactured as RIG without causing any chemical reaction with its additives.