Donald Trump was elected president on Tuesday, as he pulled off a stunning upset by riding a wave of disaffection among working class white voters and resentment at political, social and media elites.

The Associated Press and other news outlets projected that he would surpass the 270 electoral votes after the states of Wisconsin and Pennsylvania were called for him.

His victory — defying almost all predictions of Beltway pundits, pollsters and election watchers — came as he exceeded expectations in major Democratic states.

His election has enormous implications for the direction of the country, particularly since it is expected that he will take office with Republican majorities in the Senate and the House.

Clinton’s election would have made history as the first woman president, but Trump also will come to office with a number of records. At 70, he is the oldest person elected to a first term. Ronald Reagan was 69 when he was elected in 1980.

Trump is the first person elected to the White House with no government or military experience.

He is the first New Yorker elected to office since Franklin Roosevelt.

And of course, he is the first reality show star elected to office, as his years spent on NBC’s “The Apprentice” are widely credited with establishing his image as a shrewd, no-nonsense businessman, even if the avalanche of stories about his business background painted a far different picture.

Those “firsts,” however, are merely footnotes to what Trump’s campaign represented: a rebellion against insiders, whether they be in Washington, the media, Wall Street or Hollywood.

He capitalized on issues that were simmering among the ranks of the working class: the loss of jobs to China, Mexico and other countries, globalization that seemed to only speed up with the help of massive trade pacts; immigration that had changed the ethnic makeup of not just cities but many rural areas, leading to the impression that uncontrolled flows of migrants across the border were costing valuable jobs; and the continued role of the United States in the Middle East, including Iraq and Afghanistan, where the situations show little sign of improvement after trillions of dollars spent.

Trump capitalized on those issues — trade, immigration, foreign entanglements — from the start. Even if he didn’t at times offer coherent solutions, or he offered all-too simplistic ones, his ability to draw attention through a mixture of insults and schtick allowed him to dominate media time and vault to the top of the Republican pack.

By the general election, even though his campaign faltered, in the end he benefited from the drip, drip, drip revelations from WikiLeaks of a hacked email account from Clinton’s campaign chairman, John Podesta. The biggest bombshell may have been FBI director James Comey’s letter to Congress informing them that they were analyzing a new set of emails believed to be related to their investigation into Clinton’s use of a private server when she was Secretary of State. Comey announced that nothing in the emails changed their view that Clinton should not be prosecuted. Still, the attention on the issue all fed into the perception that Clinton was dishonest and untrustworthy.

Even though Trump attacked the news media like no other recent candidate — calling out reporters by name at campaign rallies and referring to members of the press as corrupt and dishonest — his very candidacy would not have been possible without it. He shook up not just the conventional wisdom of who would be ahead in the race, but of how a candidate could still thrive despite a record of outrageous comments and race-baiting rhetoric.

Despite his showbiz experience and use of reality show theatrics on the trail, Trump was largely shunned by the entertainment industry. Studio chiefs largely donated to Clinton, and she won the endorsement from rank-and-file groups such as the Actors Equity Assn. and the International Alliance of Theatrical Stage Employees. That was apparent in the way that showbiz sources contributed to the candidates, showering Clinton with contributions over Trump by lopsided margins.

The implications for the entertainment industry are potentially enormous. On the campaign trail, Trump said that he would oppose the planned merger of AT&T and Time Warner, while his pledges to renegotiate trade agreements could have a big impact on the ability of media companies to expand into foreign markets.

On a social level, Washington is in for a dramatic change, as a new cast of players take power and the Trumps put their stamp on the White House.

Some of his key players, like Steven Mnuchin, his campaign finance chairman, and Steve Bannon, his campaign CEO, have roots in the entertainment industry. Mnuchin is a major movie financier, including Warren Beatty’s upcoming “Rules Don’t Apply,” and he has been rumored to be a top pick to be Trump’s next secretary of the treasury. Bannon spent much of the 1990s working on movie financing, before he set out on a career directing and producing conservative documentaries and leading Breitbart News Network after the death of its founder, Andrew Breitbart. He also could have a significant role in the new administration.

Their presence in the ranks of Trump’s advisers, however, will be little solace to Hollywood. In a sense, Trump ran against entertainment and business elites, even though his work on “The Apprentice” and as a New York real estate mogul qualifies him for both categories. His entire campaign was run on the idea that Beltway, Wall Street and media insiders had sent the country into near ruin, and that he was the one to fix it. It became a potent populist message, allowing Trump to defy political norms and use flame-throwing rhetoric that otherwise would have washed away the careers of many other seasoned politicians.

More disconcerting, however, is the prospect that the entertainment industry’s progressives won’t have a figure in the White House who aligns with their causes — and is even hostile to many of them. That includes climate change, which Trump once called a “hoax,” and gun control.

But the loudest voices aligned against Trump warned that his statements about women, minorities and even the disabled unleashed a harsher, darker time for American politics — and in the culture.

If Trump’s presidency matches his campaign rhetoric, it’s likely that the role of Hollywood will be something akin to that of a resistance, as TV series creators, movie directors and late-night comedians put a check, creatively, on a leader they once mocked. But given his history of taking on critics by name in late-night tweet-storms, he is likely to return the compliment.