The Catalan giants were on the brink of a record-extending 13th triumph in the competition after Antoine Griezmann scored twice, either side of Oscar De Marcos' equaliser, to put Barcelona 2-1 up late on in normal time.
But Athletic, who knocked out holders Real Madrid in the semi-finals, equalised through substitute Asier Villalibre in the 90th minute and Williams scored early on in the additional period to turn the tie on its head.
Messi was then sent off in the dying moments of extra time when VAR spotted an off-the-ball incident involving Villalibre, as the Argentinian violently knocked the Athletic player to the ground.