THE Atmosphere-Space Interactions Monitor (ASIM)  is an ESA science instrument assembly, to be installed on the Columbus External Platform Facility (CEPF) of the ISS (International Space Station), to study the giant electrical discharges (lightning) in the high-altitude atmosphere above thunderstorms. The discharges are seen as optical, X and gamma-ray flashes in the stratosphere and mesosphere. The optical emissions are dubbed red sprites, blue jets, and elves or, collectively, Transient Luminous Events (TLEs); theXand gamma-ray emissions are dubbed Terrestrial Gamma Ray Flashes (TGFs), instead. The ASIM mission comprises, therefore, two main scientific instruments: the Miniature Multi-spectral Imaging Array (MMIA) composed of six cameras and six photometers and the Modular X and Gamma-ray Sensor (MXGS). We present the results obtained from Geant4  simulation programs developed for the purpose of studying the background generated by charged cosmic-ray interactions in MXGS. This work was divided in two phases. The simulation for the first stage (Phase I) was performed considering MXGS in open space and only the background due to prompt events was estimated. In the second phase (Phase II) MXGS was considered as attached to the ISS, so the geometry includes the structures surrounding the detector, to account for their modulating effect on the incident fluxes, and delayed background events due to activation were also taken into account. Since Phase II is more representative of the actual MXGS operating condition, in this paper we report its results only, although we give a description of both phases.