The 2008 election was a reminder of the demographic forces that are changing America and potentially the political balance in the country. The most diverse electorate in the nation’s history added to the favorable winds that pushed President Obama to victory. He will need the assistance of those shifts even more in 2012 if he is to avoid defeat.

Much has been made of the president’s unusual coalition in 2008 — huge turnout and overwhelming support from African Americans, the backing of Latinos, the energy of younger voters, the help from college-educated Americans and the role played by unmarried women. Part of Obama’s success was due to the excitement his candidacy generated among these groups four years ago, but part too owed simply to the realities of a nation changing in ways that are favorable to the Democrats.

The tension Obama and his advisers will confront next year is how much those inexorable demographic changes are able to overcome the effects of the economy on many of the voters who elected him four years ago and the backlash to his policies among many voters. Whatever the effect of campaign ads, candidate appearances and unforeseen events, the clash of these two underlying forces will be as important in determining who occupies the Oval Office in 2013.

Two analysts from the progressive Center for American Progress, Ruy Teixeira and John Halpin, have provided the most comprehensive examination to date of how those factors could affect the vote in 2012. The analysis is called “The Path to 270: Demographics versus Economics in the 2012 Presidential Election.”

The study examines whether the electorate in 2012 will be shaped more by the demographic changes coursing through the population, or by Republican enthusiasm to defeat the president coupled with Democratic apathy of voters hard hit by the economy and let down by Obama’s leadership.

“The stage is set for a showdown of demographics versus economics in the 2012 election,” they write. “Each side has clear strengths but also very serious weaknesses as they move into this showdown. Victory will likely go to the side most willing to acknowledge their weaknesses and attack them boldly. This will be no election for the faint-hearted.”

The 2008 electorate was 74 percent white and 26 percent minority. Given population shifts, the percentage of minorities is likely to be somewhat larger in 2012 — a key advantage for the president. Growth in the minority population, with Hispanics by far the fastest growing group in the country, was responsible for nearly all of the overall population growth in the country over the past decade, according to the 2010 Census.

As a result, Teixeira and Halpin estimate that minorities will account for at least two more percentage points in the 2012 electorate than they did in 2008. The question is whether Obama can maintain his roughly 80 percent support among minorities.

His advisers say they are confident that African American voters will continue to support him overwhelmingly and that they will again turn out to vote in very high numbers. Their confidence is backed up by much current polling.

Hispanics are a more problematic part of Obama’s coalition, and his advisers say they are not taking the Latino vote for granted. Their efforts to attract Hispanic voters are likely to be helped by the hard-line rhetoric of most of the Republican presidential candidates. But any notable drop in Hispanic support would put the president in jeopardy next year.

White voters will still make up the dominant share of the electorate next year, but the question for Obama is whether his relative strength among college-educated white voters, coupled with his minority support, can overcome his weakness with non-college-educated white voters. Four years ago, Obama lost college-educated whites by four percentage points, but he was trounced among those without college educations by 18 points and could do worse with them next year.

Teixeira and Halpin calculate that, even if there is drop-off in support among minority voters, Obama would win reelection as easily as he did four years ago so long as his deficits among white voters are the same as they were in 2008. They project that he can win narrowly even if support among white working-class voters declines to the levels seen in 2010, when Democrats lost those voters by 30 points. But there are limits. If Republicans can do as well with both white working-class and white college graduates as they did in 2010, then Obama appears destined to lose.

The two analysts go one step further to illustrate the significance of demographic shifts on presidential elections. They calculate that if Obama lost white working-class and white college graduates by the same margins that Sen. John F. Kerry (Mass.) lost them in the 2004 election — 23 points among working-class whites and 11 points among college graduates — Obama could still win the popular vote by about 50 to 48 percent.

Two groups that will be critical to Obama’s reelection are younger voters and single women. Among voters in both groups, the president has problems to overcome to ensure his reelection.

The good news for him is that voters in the millennial generation, that is those voters born between 1978 and 2000, have grown by 4 million since the last election. Millennials made up about 20 percent of the electorate four years ago, say Teixeira and Halpin, and probably will be an even larger share in 2012.

Obama won younger voters by about 2 to 1 in 2008. But enthusiasm is down and economic pessimism is up. At Obama’s Chicago headquarters, his advisers say they are laser-focused on this group. They are searching for ways to persuade those who have been disillusioned by Obama’s performance to give him another four years. Even more effort is going into turning them out again in big numbers, using smart technology and old-fashioned organizing. Still, it will be difficult for Obama to win younger voters by the margins of 2008.

Unmarried women backed Obama by an even bigger margin than younger voters in 2008 and they could be an even larger share of the electorate next year than they were four years ago. But they also have been hard hit by the economy and are perhaps even more sensitive to economic issues than younger voters. “Just as with the millennials, that gives Republicans an opening to cut into Obama’s large margins from 2008,” Teixeira and Halpin say.

Obama’s advisers see genuine challenges ahead maintaining the level of support from 2008 among unmarried women. They believe the president will be able to present a more compelling economic vision than his Republican rival, despite his lack of success in turning the economy around so far. But Democrats also will hit hard on social issues to appeal to these female voters.

All of this adds up to the kind of close election predicted for next year. Obama has some cushion, thanks to demographic changes in the country. But will it be enough to overcome the dissatisfaction with his presidency?