The world’s richest nations have long been fueled by oil, coal and natural gas, but President Obama warned Friday that less affluent countries trying to take the same path will put the planet “under water.”

In an interview with Facebook founder Mark Zuckerberg, Mr. Obama said he hoped social-media “connectivity” will help convince developing nations to eschew fossil fuels, which contribute to rising carbon-dioxide levels in the atmosphere but are also less expensive and more reliable than green energy alternatives.

“In terms of the problems we have to solve, energy is a classic example, the issue of climate change,” Mr. Obama said at the three-day Global Entrepreneurship Summit at Stanford University.

“There are entire continents, sub-Saharan Africa or the Indian sub-continent, where people are developing rapidly. They’re getting connected,” he said. “They’re going to need electricity, they’re going to need energy, but if they duplicate the ways that we produce energy here, or have in the past, then the entire planet is under water.”

The seventh annual summit, which ended Friday, hosted 1,200 entrepreneurs and investors from 170 nations, including for the first time Cuba. The Obama administration announced in December 2014 that it would restore full diplomatic relations with Cuba and end a 54-year-old trade embargo with the communist island nation.