"A lot of the folks who are running for a certain office who shall go unnamed, they've been talking down new sources of energy," Obama said. "They dismiss wind power. They dismiss solar power. They make jokes about biofuels. They were against raising fuel standards. I guess they like gas-guzzlers."
The president was speaking to an enthusiastic crowd at Prince George's County Community College just outside Washington, D.C.
Obama said while the U.S. is producing more oil than at any time in the past eight years, drilling alone will not solve the country's energy problems.
"We're drilling all over this country. I guess there's some empty spots where we're not drilling. We're not at the national mall. We're not drilling at your house," Obama joked during his speech.
Republican presidential candidates have criticized the president for the sharp rise in gas prices. One of the most vocal critics of Obama's energy policies has been former House Speaker Newt Gingrich, who has referred to Obama as "President Algae" for speaking of research that one day would allow oil and gas to be developed from algae.
The Associated Press contributed to this report.