President Barack Obama speaks during a memorial service for the miners killed in the Upper Big Branch Mine, in Beckley, W.Va.AP

U.S. President Barack Obama (4th L) and Vice President Joe Biden (3rd L) watch on as West Virginia Governor Joe Manchin escorts a young relative of a coal mining victim to place a helmet and light on a cross. (REUTERS)

BECKLEY, W.Va. — They lived and they died pursuing the American Dream, working in dangerous conditions underground to help keep the lights on across the country, a somber President Barack Obama said today in a eulogy to the workers who died in the worst mine accident in a generation.

The president told the families of the workers killed in the Upper Big Branch mine, about 35 miles from here, that the nation would honor their memories by improving safety in the mines.

“How can we fail them? How can a nation that relies on its miners not do everything in its power to protect them?” Obama said. “How can we let anyone in this country put their lives at risk by simply showing up to work, by simply pursuing the American Dream?”

With workers’ families sitting near him — and the Massey Energy Co. executive who runs the mine sitting near the rear of the hall — Obama spoke broadly about the 29 workers killed in the explosion.

“In coveralls and hard-toe boots, a hardhat over their heads, they would sit quietly for their hourlong journey, 5 miles into a mountain, the only light the lamp on their caps, or the glow from the mantrip they rode in,” Obama said.

“Most days, they would emerge from the dark mine, squinting at the light. Most days, they would emerge, sweaty, dirty, dusted with coal. Most days, they would come home. Most days, but not that day.”

Investigators have detected high levels of two potentially explosive gases inside the mine, and it could be a month before investigators can get inside to determine what caused the April 5 blast. Federal regulators have identified highly explosive methane gas, coal dust or a mixture of the two as the likely cause of the blast, but the ignition source is unknown.

The explosion will be the subject of a Senate hearing on Tuesday, with the nation’s top mine safety official expected to testify.

Obama has ordered a broad review of coal mines with poor safety records and urged federal officials to strengthen laws he previously called “so riddled with loopholes that they allow unsafe conditions to continue.”

Vice President Joe Biden, speaking before Obama, called miners “the spine of this nation” and “roughneck angels.” He said the time would come to account for the safety conditions that led to the disaster.

“As a community, and as a nation, we would compound tragedy if we let life go on unchanged,” he said. “Certainly, no one should have to sacrifice their life for their livelihood.”

Obama and Biden both noted that the mining industry is more than a source of jobs in coal country — it’s a source of energy for the entire nation.

“The men we remember here today went into the darkness so we could have light,” Biden said. “It was dangerous work and they knew it. But they never flinched.”

Obama linked the West Virginia deaths with the challenges Americans face from coast to coast amid a sour economy.

“All that hard work. All that hardship. All the time spent underground. It was all for the families. It was all for you,” Obama said. “For a car in the driveway. For a roof overhead. For a chance to give their kids opportunities that they would never know, and enjoy retirement with their spouses. It was all in the hopes of something better.

“So these miners lived — as they died — in pursuit of the American Dream.”

Before the somber memorial service, Obama and Biden met privately with the families of the 29 people killed in the explosion.

A row of 29 white crosses lined the main stage. Behind it were photos of the miners, and to the side stood a large wreath with 29 white roses, along with two yellow ones honoring two injured miners.

As West Virginia first lady Gayle Manchin read the miners’ names, each of their families entered and placed a miner’s helmet on a corresponding cross.

Gov. Joe Manchin also promised action to improve mine safety. “It takes brave men to work below the surface,” he said. “I pledge to you: Your loved ones will not have died in vain.”

Many people who gathered for the service wore black ribbons with gold shovels and pick axes; some wore coal miners’ reflective clothing. Don Blankenship, chief executive of Massey Energy, mingled with the crowd before taking his seat near the back of the floor in the Beckley-Raleigh Convention Center.

Jean Cook of Pineville displayed a new tattoo on the back of her right shoulder in honor of her 21-year-old nephew, Adam Morgan, who died in the mine explosion. Cook said she was reluctant to attend the memorial because it would take her days to recover.

“Did I want to? Emotionally, no,” she said. “All this has done a toll on my nerves. I just constantly cry. I don’t think there’s anything anybody can say.”