Ma Sanbao was initially a servant of Chai Shao, the husband of Li Yuan's daughter Princess Pingyang.
When Li Yuan's main force arrived, Pingyang and Ma Sanbao had already cleared most Sui garrisons around Chang'an.
[5] After Tang dynasty was officially established, Ma Sanbao participated in campaigns against Xue Renguo and Tuyuhun as a subordinate to Chai Shao.
In the battle at Minzhou, he killed a prince of Tuyuhun and captured thousands of enemy soldiers.
After that, Ma Sanbao joined Tang army and became one of four close guards protecting Li Shimin (along with Duan Zhixuan, Yin Kaishan and Liu Hongji).