Sonam Gyatso, after being granted the grandiose title by Altan Khan, departed for Tibet. Before he left, he sent a letter and gifts to the Ming Chinese official Zhang Juzheng (1525–1582), which arrived on March 12, 1579. Sometime in August or September of that year, Sonam Gyatso's representative stationed with Altan Khan received a return letter and gift from the Wanli Emperor (r. 1572–1620), who also conferred upon Sonam Gyatso a title; this was the first official contact between a Dalai Lama and a government of China. However, Laird states that when Wanli invited him to Beijing, the Dalai Lama declined the offer due to a prior commitment, even though he was only 400 km (250 mi) from Beijing. Laird adds that "the power of the Ming emperor did not reach very far at the time." Although not recorded in any official Chinese records, Sonam Gyatso's biography states that Wanli again conferred titles on Sonam Gyatso in 1588, and invited him to Beijing for a second time, but Sonam Gyatso was unable to visit China as he died the same year in Mongolia working with Altan Khan's son to further the spread of Buddhism.
Who granted Sonam Gyatso the title of grandiose?
Altan Khan