A 30-foot-long sperm whale weighing more than 8 tons was euthanized after stranding itself in shallow surf along the Texas coast.

The whale washed up about 40 feet from the shore Tuesday on Mustang Island. Onlookers watched it thrash about before veterinarian Tim Tristan gave the whale a huge dose of tranquilizers.

Marine mammals beach themselves only when something is seriously wrong, he said.

"This animal stranded for a reason," Tristan said. "It can be heartbreaking, but all we could do was make it comfortable."

A necropsy to see why the whale was sick was scheduled for Wednesday.

Lea Walker, a regional director with the Texas Marine Mammal Stranding Network, said the whale was too big to transport or hold in a tank to rehabilitate.