Barack Obama’s main opponents in his presidential general elections were John McCain in 2008 and Mitt Romney in 2012.

Here’s a bit more context in a quick, readable way.

Main Opponents in Each Election

  • 2008: Republican Senator John McCain of Arizona ran against Obama, with Sarah Palin as his running mate.
  • 2012: Republican former Massachusetts governor Mitt Romney ran against Obama, with Paul Ryan as his running mate.

Simple HTML Table of Obama’s General Election Opponents

[7][1][5] [1][5][7] [5][7][1] [4][10][3][1] [10][3][4][1] [3][1]
Election Year Obama’s Role Main Opponent Opponent’s Party Opponent’s Running Mate
2008 Democratic nominee for president John McCainRepublicanSarah Palin
2012 Incumbent Democratic president Mitt RomneyRepublicanPaul Ryan

Quick Note on Primaries

If you were thinking about within his own party rather than the general election:

  • In the 2008 Democratic primaries, his main rival was Hillary Clinton.
  • In 2012, as an incumbent, Obama did not face a serious primary challenger.

TL;DR: Obama ran against John McCain in 2008 and Mitt Romney in 2012 in the presidential general elections.