​A 25-foot humpback whale that has been ​grounded on a sandbar in Moriches Bay for nearly a week was euthanized Wednesday.

Officials used an injectable medication to kill the ​sea mammal after numerous failed attempts to free it from the Long Island sandbar, where it has been thrashing around since the weekend.

A National Oceanic and Atmospheric Administration medical team made the call to ​put the whale down after a crew of veterinarians jetted out Wednesday afternoon to observe its deteriorating condition.

The vets determined that the ​baby​ whale was weak, had neurological abnormalities and may have been battling an infection.

They will conduct a necropsy to determine its official cause of death and what led it to become trapped in the shallow waters.

The sea beast was first spotted swimming near Long Island last week, but didn’t get stuck until Saturday.

Biologists went out on a boat Sunday to examine the whale. They used the boat to create waves that they hoped would help it escape, but were ultimately unsuccessful.

Long Island residents have been monitoring the whale’s plight from the beach over the last few days — and many are furious that officials didn’t act quicker to save it.

Gov. Cuomo deferred to the NOAA Tuesday, but urged the federal agency to “do everything possible to save the whale,” he said in a statement.

“The Governor understands that any chance of survival should justify the maximum effort and he is committed to providing it,” the statement added.

With Post Wires