Wei Gao was born in 745, during the reign of Emperor Xuanzong. His family was from Jingzhao Municipality (京兆, i.e., the region of the Tang Dynasty capital Chang'an). HIs sixth-generation ancestor Wei Fan (韋範) had accomplishments during Tang's two predecessor dynasties, Northern Zhou and Sui Dynasty.
Early in the Dali era (766-779) of Emperor Xuanzong's grandson Emperor Daizong, Wei served as one of the ceremonial pallbearers for the burial of Emperor Xuanzong's son and Emperor Daizong's father Emperor Suzong, and thereafter was made an officer at Hua Prefecture (華州, in modern Weinan, Shaanxi). In 782, during the reign of Emperor Daizong's son Emperor Dezong, when the chancellor Zhang Yi was made the military governor (Jiedushi) of Fengxiang Circuit (鳳翔, headquartered in modern Baoji, Shaanxi), he invited Wei to serve on his staff as an assistant overseeing military farming, and also put Wei in charge of the army stationed at Long Prefecture (隴州, in modern Baoji).
In 783, soldiers from Jingxuan Circuit (涇原, headquartered in modern Pingliang, Gansu), at Chang'an to await deployment to the east for wars against warlords, mutinied after not receiving rewards that they believed they deserved, and Emperor Dezong fled to Fengtian (奉天, in modern Xianyang, Shaanxi). The Jingyuan soldiers supported Zhang Yi's predecessor as military governor of Fengxiang Circuit, Zhu Ci as their leader. As Zhu Ci had been removed from his command by Emperor Dezong due to a rebellion by his brother Zhu Tao, he resented Emperor Dezong, and he soon declared himself emperor of a new state of Qin. The Fengxiang officer Li Chulin (李楚琳) mutinied, killed Zhang, and submitted to Zhu. Meanwhile, another former subordinate of Zhu's, Niu Yun'guang (牛雲光), stationed at Long Prefecture, was ready to rise against Wei and seize Long Prefecture for Zhu, but when he was discovered, he fled toward Chang'an. On the way, however, he met Zhu's emissary Su Yu (蘇玉), who wanted to try to persuade Wei to submit, and thus they returned to Long Prefecture together. Wei pretended to be ready to submit, but instead, after welcoming them into the city, killed them. He then led the soldiers in swearing an oath to Emperor Dezong, sent his cousins Wei Ping (韋平) and Wei Yan (韋弇) to Fengtian to report the events to Emperor Dezong, and also sought aid from Tufan. Emperor Dezong made Long Prefecture into its own circuit — Fengyi Circuit (奉義) and made Wei its military governor. Zhu then sent another emissary to Wei, promising to make him the military governor of Fengxiang; Wei executed the emissary. After Zhu was defeated and Emperor Dezong returned to Chang'an in 784, he summoned Wei and made him a general of the imperial guards. Under the suggestion of the chancellor Xiao Fu, he also considered Wei as a possible replacement for Chen Shaoyou (陳少遊) as the military governor of Huainan Circuit (淮南, headquartered in modern Yangzhou, Jiangsu), but did not actually do so.
In 785, Emperor Dezong made Wei Gao the military governor of Xichuan Circuit, replacing Zhang Yanshang. In 787, with Tufan making repeated incursions into Tang territory and Tufan's vassal Nanzhao (which had previously been a Tang vassal) making overtures to Wei indicating that its king Yimouxun (異牟尋) was considering resubmitting to Tang, Wei, with Emperor Dezong's approval, wrote to Yimouxun, seeking further reconciliation between Tang and Nanzhao. He also seek to aid the effort persuading Ju Nashi (苴那時), the chieftain of Nanzhao's neighbor Wudeng Tribe (勿鄧), to serve as a go-between.
In 788, when Tufan was ready to launch a campaign against Xichuan Circuit with 100,000 men, it requested Nanzhao to also mobilize and aid its forces. Wei, knowing that Yimouxun was hesitating in his choice between the two potential suzerains, wrote a letter addressed to Yimouxun congratulating him on agreeing to submit to Tang — and intentionally had the letter delivered to Tufan through Nanzhao's neighboring tribes (collectively known as the Dongman (東蠻), located in modern Liangshan Yi Autonomous Prefecture, Sichuan). Tufan, beginning to suspect Nanzhao's loyalty, stationed 10,000 men on the road between Tang and Nanzhao. Yimouxun, in anger over this action, withdrew his own troops and did not aid in the Tufan campaign. Wei subsequently defeated Tufan forces at Qingxi Pass (清溪關, in modern Ya'an, Sichuan), and after several further defeats, Tufan forces withdrew.
In 789, Wei sent his officer Cao Youdao (曹有道), in conjunction with forces of Dongman and Lianglinman (兩林蠻, located in modern Liangshan), attacked Tufan's Qinghai (青海) and Lacheng (臘城) Circuits (both located southeast of Qinghai Lake), and the forces battled at Xi Prefecture (雟州, in modern Liangshan). The Tufan forces were defeated, and during the battle, and the Tufan general Qizang Zhezhe (乞藏遮遮) was killed. It was said that after Qizang's death, Wei was continuously successful against Tufan forces over the next few years, recapturing Xi Prefecture.
Meanwhile, Wei was continuously writing to Yimouxun, but Yimouxun did not respond. Nevertheless, Nanzhao was sending fewer and fewer men to assist Tufan on campaigns. In 791, Wei made further overture to Nanzhao by sending his officer Duan Zhongyi (段忠義), who was originally from Nanzhao and who had served as an emissary for Yimouxun's grandfather Geluofeng (閤羅鳳), as an emissary back to Nanzhao. (This drew an incident between Tufan and Nanzhao when Tufan found out, forcing Yimouxun to turn someone with a similar profile to Duan to Tufan. Tufan further reacted by demanding that Nanzhao officials' sons be sent to Tufan as hostages to ensure Nanzhao's loyalty, and the Nanzhao people became further resentful of Tufan.) Around this time, there was also an incident when the chief of Wudeng, Ju Mengchong (苴夢沖), resubmitted to Tufan and was cutting off the communication line between Tang and Nanzhao, and Wei sent an army to kill Ju, reopening the communication line.
In 792, Wei attacked Wei Prefecture (維州, in modern Ngawa Tibetan and Qiang Autonomous Prefecture, Sichuan) and captured the Tufan general Lun Zanre (論贊熱). In 793, when Emperor Dezong ordered the reconstruction of Yan Prefecture (鹽州, in modern Yulin, Shaanxi), he was concerned that Tufan forces might attack the Tang forces rebuilding Yan Prefecture before the walls can be completed, so he ordered Wei to attack Tufan to distract Tufan forces; Wei's attack captured some 50 Tufan fortifications, and as a reward, Emperor Dezong gave him the honorary title of acting You Pushe (右僕射). Meanwhile, he finally received a positive response from Yimouxun on his repeated overtures, as Yimouxun sent three emissaries bearing tributes of gold (to show firmness) and cinnabar (to show honesty) in late 793. Wei had the Yimouxun's emissaries escorted to Chang'an and then back to Nanzhao, sending with them his officer Cui Zuoshi (崔佐時) with an imperial edict and his own letter. When Cui arrived in Nanzhao in spring 794, he persuaded Yimouxun to finally turn against Tufan and back to Tang. Subsequently, Tufan launched a surprise attack on Tufan, capturing more than 100,000 men, and formally submitted to Tang, greatly reducing Tufan's abilities to attack Tang.
In 796, Wei Gao was given the honorary chancellor title of Tong Zhongshu Menxia Pingzhangzhi (同中書門下平章事). Meanwhile, it was said that he kept in Emperor Dezong's good graces by offering daily tributes to Emperor Dezong. In 801, with Emperor Dezong ordering him to attack Tufan to divert Tufan's attentions from the northern regions, he, in joint operation with Yimouxun, attacked a number of Tufan outposts and burned them, killing over 10,000 Tufan soldiers in the process. To reward Wei, Emperor Dezong gave him honorary titles of acting Situ (司徒, one of the Three Excellencies) as well as Zhongshu Ling (中書令), and created him the Prince of Nankang. Subsequently, Wei put Wei Prefecture and Kunming (昆明, in modern Liangshan, not modern Kunming) under siege; when a Tufan army under the command of the general Lun Mangre (論莽熱) came to try to lift the siege, Wei engaged him and captured him. However, with Wei's own army suffering major losses, he was forced to withdraw.
In 805, Emperor Dezong died and was succeeded by his severely ill son Emperor Shunzong. Emperor Shunzong gave Wei the honorific title of acting Taiwei (太尉, also one of the Three Excellencies). Meanwhile, Emperor Shunzong's close associate Wang Shuwen became powerful, and Wei sent his deputy military governor, Liu Pi, to Chang'an, to meet with Wang, requesting that Wei be put in charge of not only Xichuan, but also two neighboring circuits — Dongchuan (東川, headquartered in modern Mianyang, Sichuan) and Shannan West (山南西道, headquartered in modern Hanzhong, Shaanxi). Liu, apparently under Wei's instruction, informed Wang:
The Taiwei asked me, Liu Pi, to give you his regards. If you give him the Three Chuans [(i.e., Xichuan, Dongchuan, and Shannan West)], he will support you to his death, and if you do not, he will repay you in other ways.
Wang, in anger, wanted to kill Liu, but was stopped by the chancellor Wei Zhiyi. Meanwhile, when Yang Shi'e (羊士諤), an official from Xuanshe Circuit (宣歙, headquartered in modern Xuancheng, Anhui), also made demands to Wang on behalf of his superiors, Wang exiled Yang. When Liu heard this, he fled back to Xichuan and reported to Wei. Apparently in response, Wei submitted a strongly worded petition denouncing Wang and his partisans. Wei also wrote a letter to Emperor Shunzong's crown prince Li Chun, urging him to take over as regent, to which Li Chun reacted favorably. Wei's petition was followed by those from two other senior military governors, Pei Jun (裴均) and Yan Shou (嚴綬), which much shocked Wang's partisans. Soon thereafter, with Wang forced to leave governmental service due to his mother's death and Emperor Shunzong thereafter passing the throne to Li Chun (as Emperor Xianzong) later in 805, Wang and his partisans lost power and were purged.
Late in 805, Wei died and was given great posthumous honors. According to the Song Dynasty historian Sima Guang, who harmonized the commentaries about Wei in the Old Book of Tang and the New Book of Tang:
Wei Gao was at the Bashu region [(i.e., modern Sichuan)] for 21 years. He initially increased the tax burdens and extracted wealth; he gave plenty of tributes to the emperor to cause the emperor to favor him; he awarded much treasure to the soldiers to get the soldiers to be grateful to him. When the soldiers had weddings, funerals, or casualties, Wei made sure that they were well-supplied, so he was able to keep his positions for a long time, and the soldiers were happy to serve under him. While he was serving, he persuaded Nanzhao to submit and inflicted injuries on Tufan. He sent his senior staff members out to the prefectures to serve as prefects, and once their terms were over, he recalled them to serve on his staff, but he continuously made sure that they did not return to Chang'an, to avoid their reporting to the emperor what he was doing. After the treasury was filled, he then was lenient to his people, and every three years, he exempted their taxes once. The people of Bashu respected his intelligence and feared his might. Even today [(i.e., during Sima's time)], the people treated him as a Tudi [(i.e., local god)], and the households all have his pictures on the wall to offer sacrifices to.