Solemn in the face of tragedy, President Donald Trump visited hospital bedsides and a vital police base in stricken Las Vegas on Wednesday, offering prayers and condolences to the victims of Sunday night's shooting massacre, along with the nation's thanks to first responders and doctors who rushed to save lives.

"America is truly a nation in mourning," the president declared, days after a gunman on the 32nd floor of a hotel and casino opened fire on the crowd at an outdoor country music festival below. The rampage killed at least 58 people and injured more than 500, many from gunfire, others from chaotic efforts to escape.

In Las Vegas, Trump spoke of the families who "tonight will go to bed in a world that is suddenly empty."

"Our souls are stricken with grief for every American who lost a husband or a wife, a mother or a father, a son or a daughter," he told them. "We know that your sorrow feels endless. We stand together to help you carry your pain. "

It was a somber address from a provocateur president who prides himself on commanding strength but sometimes has struggled to project empathy at times of tragedy.

His solemn words in Las Vegas offered a sharp contrast to his trip a day earlier to hurricane-ravaged Puerto Rico, where he spoke of the "expensive" recovery effort on the island and highlighted the relatively low death toll there compared with "a real catastrophe like Katrina" in 2005.

On Wednesday, Trump took a grim tour of Las Vegas, meeting face-to-face with victims and first responders.

In prepared remarks, he spoke of the courage displayed by those who risked or lost their lives saving loved ones and total strangers. He described an eyewitness account of police officers standing as bullets slammed around them and trying to direct concert-goers to safety.

He described a military veteran who had rushed to the scene in search of loved ones, but quickly turned to helping victims, using plastic barriers as gurneys for the injured and frantically searching for anything he could use to make splints.

"The example of those whose final act was to sacrifice themselves for those they love should inspire all of us to show more love every day for the people who grace our lives," Trump said.

The president spent about four hours in a city still reeling from the worst mass shooting in modern American history.

His first stop was the University Medical Center, where he spent over 90 minutes visiting with recovering victims, some with severe injuries, and listening to their stories. While a serious visit, White House spokeswoman Sarah Huckabee Sanders said there was laughter and celebration in some of the visits with eight families affected by the shooting. Trump also met with about 100 medical professionals.

Sanders said the visit was a moving experience for the president, who stayed longer at the hospital than planned and amended his formal remarks after the hospital trip.

Trump said after the visit that he'd met "some of the most amazing people" and invited them to visit the White House if they're ever in Washington.

Generous with superlatives, Trump also commended the doctors for doing an "indescribable" job.

One of the patients who met with Trump told The Associated Press he was "super nice and super caring."

Tiffany Huizar, 18, a high school student who lives in Santa Ana, Calif., is recovering from bullet wounds in the stomach and elbow. She said Trump "was very comforting and like a father figure. ... I feel like a lot of people have negative views about him and what he posts on Twitter and social media and he was absolutely a different guy today in the hospital."

Trump then headed to the Las Vegas Metropolitan Police headquarters, where he met with officers, dispatchers and others who'd responded to the shooting Sunday night.

"You showed the world, and the world is watching," he told them, "and you showed what professionalism is all about."

Until his final remarks, Trump focused his comments during the trip on praising recovery efforts and offering congratulations to police officers, medical professionals and survivors, rather than on grieving the dead. At the last stop, however, he spoke slowly and somberly of the lives ended or forever altered.

Trump did not visit the site of the shooting, but on his trip from the airport, his motorcade drove past the Mandalay Bay hotel where the gunman fired down into the concert crowd. He also passed his own Trump hotel on his way toward the entertainment strip.

Trump has a long personal connection to Las Vegas — a city where his name is written in huge golden letters atop his hotel. He also campaigned extensively across Nevada during his presidential campaign, drawing large crowds to rallies along the strip.

As he has done all week, Trump batted away questions about whether the shooting warranted taking a fresh look at tougher gun controls.

"We're not going to talk about that today," he said. "We won't talk about that."

Republicans who control Congress have made clear they have no intention of taking up stricter gun control measures in the shooting's aftermath. However, senior GOP lawmakers said late Wednesday they could consider legislation banning "bump stocks" like the shooter in Las Vegas apparently used to effectively convert semi-automatic rifles into fully automated weapons.

Trump, elected with strong support from the National Rifle Association and with a pledge to protect the Second Amendment, endorsed a prohibition on assault weapons in a 2000 book.

Colvin reported from Washington. Associated Press writers Amanda Lee Myers in Las Vegas and Ken Thomas in Washington contributed to this report.