The invention discloses a silver-containing silicon-based mesoporous antibacterial agent and a preparation method thereof. The method comprises the following steps: mixing structure-directing agent of polyethylene glycol-polypropylene glycol-polyethylene glycol block copolymer, deionized water and acid, adding silicon source and silver source, then heating, continuously stirring to obtain sol-gel, drying sol-gel in vacuum, then washing with ethanol, drying in vacuum; and roasting the product of vacuum drying in protective gas. The antibacterial active silver is added during the preparation process of the mesoporous material, so that the silver ion can be deposited on the hole wall of mesoporous, then a physical or chemical method is used to remove the structure-directing agent of mesoporous and finally the silver-containing mesoporous inorganic antibacterial agent is prepared. The antibacterial agent is characterized in that the content of the antibacterial active body is easy to control, the preparation method is easy, the antibacterial property is strong and stable, the antibacterial effect can last for long time, the color of the antibacterial agent is not easy to change, the antibacterial agent is nontoxic, etc. The antibacterial agent can be widely used in fields such as ceramics, plastics, textile, coatings, water treatment and the like.