Machito, the African elephant who awed Zoo Miami visitors for more than three decades, has died after battling pneumonia for several weeks.

Trainers made “the difficult yet humane” decision to euthanize the 32-year-old Machito on Wednesday after weeks of treatment and consultations with top elephant experts from around the world.

“This is the first elephant to die in the history of Zoo Miami and it has brought extreme sorrow to the zoo’s staff and volunteers,” said Ron Magill, the zoo’s spokesman.

Born and orphaned in Zimbabwe, Machito arrived at the zoo — then called Miami Metrozoo — in November 1981 when he was a year and a half. His herd was slaughtered in Zimbabwe. In Miami, he met Peggy and Maybel, two African elephants already in resident.

He was the zoo’s first African bull elephant, a notoriously temperamental species. Yet, Machito never gave trainers much problems. And unlike in the wild, where African bull elephants lead solitary lives, Machito readily socialized with the females, though he never fathered any offspring.

Machito became a favorite over the years, drawing the attention of even celebrity guests.

“Shaquille O’Neal loved him. He told me he appreciated what it was like to be a big boy,” Magill said. “And Michael Jackson, who brought his kids to the zoo, was very intrigued by him.”

Several weeks ago, Machito began suffering from stiff limbs, then lethargy and a loss appetite. He ate little, lost hundreds of pounds and labored to breathe. Veterinarians began treating him with antibiotics. In recent days, his health began to seriously deteriorate and he became more unresponsive.

Zoo video cameras revealed that the 9,000-pound animal could not lie down or sleep. He occasionally took naps leaning against the bars of the barn where he was under observation. He had abscesses and circulation problems in his legs.

Zoo Miami called elephant experts worldwide, but no one could figure out how to save one of the zoo’s most famous inhabitants.

The pneumonia, detected by a necropsy, likely would have killed Machito had he not been euthanized.

Machito’s death is considered premature because African elephants can live well into their 60s. More tests, expected to be completed in the coming weeks, will likely show how the elephant contracted pneumonia.

Meanwhile, visitors Wednesday began bringing flowers in Machito’s honor to the elephant exhibit.

The Southwest Miami-Dade zoo also features three Asian elephants: a 46-year-old male, Dahlip, and two females, Nellie, 43, and Maude, 39.