Thurman - previously undefeated - had promised to send the 40-year-old Fillipino into retirement, but was knocked down in the first round before a thrilling fight went the distance.
"I knew it was too close," said American Thurman. "He got the knockdown so he had momentum in round one. This was a beautiful night of boxing." The 30-year-old had been looking for his 30th straight win.
Two judges scored it 115-112 to Pacquiao, while the other gave it 114-113 to Thurman.
Pacquiao - a world champion at eight weights - was fighting for the 71st time in a stellar career that has seen seven defeats, but with four of those losses coming in his past 11 fights before the meeting with Thurman.
Afterwards, Pacquiao said he felt "blessed" and he will return to the Philippines to resume his work as a senator before deciding his next move.
"I think I will fight next year," he added.