(Recasts with confirmation of vote, adds Musk comments, details, paragraphs 1, 4-6, 12)

* Social media campaign helps garner rare small-investor support

* Win for Musk despite opposition from major institutions

SAN FRANCISCO, June 13 (Reuters) - Elon Musk's army of small-investor allies took a victory lap on Thursday as the Tesla CEO won a critical shareholder vote for his $56 billion pay package despite opposition from major institutions.

Mom-and-pop investors, who hold an unusually high share of the electric-vehicle maker, are typically apathetic toward voting. But in an unusual show of support, many had been campaigning on social media for weeks for the celebrity billionaire CEO's pay to be reinstated after a Delaware judge voided it in January because she found that Musk had improperly controlled the process.

"We have the most awesome shareholder base," Musk said at the shareholder meeting after the vote was announced. "Hot damn, I love you guys," he said to a roaring and applauding crowd of investors at the Tesla factory in Austin, Texas.

Backing from retail shareholders along with support from some big institutional investors was key to turning the vote in Musk's favor, a source familiar with the preliminary tally told Reuters on Wednesday, after the CEO tipped off on social media platform X that the proposal was garnering huge support.

"Tesla's retail shareholders aren't just passively adding shares to their portfolio. They're participating in running and advancing the company," said Omar Qazi in a post on X from the handle @WholeMarsBlog. "They vote. They tell their friends. It's not just about investing. It's a movement," said Qazi who has more than 476,000 followers.

Institutional investors have been divided on the issue. While some supported Musk's pay, others such as California Public Employees' Retirement System and proxy firms Glass Lewis and Institutional Shareholder Services urged shareholders to reject the pay package, calling the compensation excessive.

"When both the institutions and the proxy advisory firms are leaning in one direction, it's very rare for the vote to come out the other way," John Lawrence, a partner at law firm Baker Botts, told Reuters. "It shows in this case the company's understanding of the power of social media."

'WE HAVE YOUR BACK'

Musk enjoys a global fan base for transforming Tesla from a startup to a behemoth and for innovation at his other companies including rocket maker SpaceX. But standing up to powerhouse investors who voted "no" on the pay package required more than just a fan base.

Social media has been abuzz for weeks with many users, such as Alexandra Merz, who posts on X as @TeslaBoomerMama, calling on people to vote. The efforts prompted some non-U.S. banks and brokerages to allow Tesla investors to vote, which was not previously the case.

"Don't mess with Tesla Retail Shareholders," Merz, who attended the meeting and received a standing ovation from investors for her endeavors, posted on X. "Your votes will help to remedy a true injustice."

Musk himself has also been actively wooing their support with regular social media posts. He had set up a separate website to educate investors on the proposals, which also included reincorporating the company in Texas, and on how to vote. The company's board sent regular letters to shareholders highlighting Musk's importance to Tesla and alluding to the risks of losing his involvement if the pay package was rejected. Musk even offered tours of Tesla's factory to some investors who voted.

The plan worked. About 90% of the retail investors who voted were in favor, Musk said in a post on X over the weekend. The approval is critical as Musk faces an uphill legal fight to convince the Delaware judge who said the Tesla board was "beholden" to him, while Tesla might also field fresh lawsuits over the latest vote. Still, small investors assured their continued support.

"Shareholders have spoken, again, and hopefully now our votes can officially count," X user Alicia said in a post. "@elonmusk, we've always believed in you and will continue to do so. We have your back!" (Reporting by Abhirup Roy in San Francisco; Additional reporting by Greg Roumeliotis; Editing by Matthew Lewis)