The gunman who went on a shooting rampage in a popular gay nightclub here shot nearly all of his victims in the first stages of the assault, then was utterly “cool and calm” while he talked by phone to law enforcement officials about further carnage, claimed allegiance to the Islamic State and praised the Boston Marathon bombers, officials said on Monday.

As officials offered new details about the worst mass shooting in American history, which left 49 people dead and 53 wounded, Chief John Mina of the Orlando Police Department said that the gunman, Omar Mateen, 29, told police negotiators — falsely, they later discovered — that he had explosives and accomplices at Pulse nightclub.

Mr. Mateen eventually made comments persuading them that “there would be an imminent loss of life,” Chief Mina said, prompting the chief to end a three-hour standoff and order the assault that killed Mr. Mateen and freed dozens of people trapped in the club.

President Obama, speaking to reporters at the White House, said it appeared the attack was “an example of the kind of homegrown extremism that all of us have been concerned about,” with a gunman who was inspired by radical material he found online.

Even as American military forces and intelligence agencies attack the Islamic State and other extremist groups, Mr. Obama said, “one of the biggest challenges we are going to have is this kind of propaganda and perversions of Islam that you see generated on the internet.”

New information also emerged Monday on Mr. Mateen, including frightening statements he made three years ago to co-workers at a local courthouse about being tied to terrorism, and that the resulting F.B.I. investigation was extensive, lasting 10 months.

“First he claimed family connections to Al Qaeda,” which, like the Islamic State, is a Sunni Muslim terrorist group, James Comey, the F.B.I. director, said Monday. “He also said he was a member of Hezbollah,” a Shiite group in conflict with Al Qaeda and the Islamic State.

“He said he hoped that law enforcement would raid his apartment and assault his wife and child so that he could martyr himself,” Mr. Comey said.

“Our investigation involved introducing confidential sources to him, recording conversations with him, following him, reviewing transactional records from his communications,” and searching government records for mentions of him, the director said. “We then interviewed him twice. He admitted making the statements his co-workers reported, but explained that he did it in anger because he thought his co-workers were discriminating against him and teasing him because he was Muslim.”

The F.B.I. closed the investigation, and Mr. Mateen continued working as a security guard for a private firm G4S.

The Florida Department of Corrections revealed on Monday that before working for G4S, Mr. Mateen worked briefly as a state prison guard. Alberto C. Moscoso, a department spokesman, said that Mr. Mateen worked at Martin Correctional Institution from October 2006 to April 2007, but did not say why he left.

The government of Saudi Arabia reported on Monday that Mr. Mateen had traveled to that country twice to make a religious pilgrimage known as the umrah. The Interior Ministry said he had visited in March 2011 for 10 days, and in March 2012 for eight days.

Investigators were hunting for any indication that Mr. Mateen might have had help in planning or carrying out the slaughter, and they continued combing through the battered, blood-spattered wreckage of Pulse for clues.

“So far, we see no indication that this was part of a plot directed from outside the United States,” Mr. Comey said.

After a night in which dozens of bodies were removed from the scene, Mayor Buddy Dyer said on Monday that 48 of the 49 dead victims had been identified, and the families of 46 of them had been notified.

Mr. Mateen had a chilling history that included talking about killing people, beating his former wife and voicing hatred of minorities, gays and Jews; most of his victims were gay, Latino, or both. His father, Seddique Mir Mateen, an Afghan immigrant, has said that he was particularly enraged by seeing a same-sex couple kiss, though the elder Mr. Mateen said in a video he posted online that he believed that it was up to God to punish gays. But on Monday, the father, teary-eyed, told reporters that he had no inkling of what was to come.

“If I knew 1 percent about what he was doing, I would have called the F.B.I.,” the elder Mr. Mateen said. “He went against my principles as a father and as a U.S. citizen.”

Chief Mina said that an off-duty officer who had been working at Pulse responded to shots fired at about 2 a.m. Sunday. Additional officers rushed to the scene, he said, and entered the nightclub, where they engaged in a gun battle with Mr. Mateen, forcing him to retreat to a bathroom where officers believed he had four to five hostages. About 15 to 20 people were in another bathroom.

“At that time we were able to save and rescue dozens and dozens of people and get them out of the club,” Chief Mina said. A SWAT team was called and took up positions in a bathroom across from where Mr. Mateen had taken cover.

From that point, “it kind of stabilized and the suspect had barricaded himself in the bathroom,” and there was no shooting during the subsequent standoff, the chief said. Mr. Mateen called 911, beginning a series of calls and conversations with the police, in which he declared allegiance to the Islamic State, the terrorist group that has taken over parts of Syria, Iraq and Libya. The attackers who killed 14 people in San Bernardino, Calif., in December also stated their allegiance to the group.

“He was cool and calm when he was making those phone calls to us,” Chief Mina said. “We had a team of crisis negotiators that did talk to the suspect, just trying to get as much information as possible, and they focused on what they could do to resolve the situation.”

But, he added, “he really wasn’t asking for a lot and we were doing most of the asking.” Asked about reports that Mr. Mateen was laughing or celebrating, the chief said there was no sign of that in the phone conversations.

“There was talk about bomb vests, about explosives, throughout,” and eventually “there were statements made about imminent loss of life.”

Law enforcement officials decided to mount an assault on the club, but an explosive placed on the wall did not penetrate completely, so officers used an armored vehicle to punch a hole about two feet off the ground, allowing hostages to flee, the chief said. Mr. Mateen also came through the breach in the wall, Chief Mina said, and was killed in a shootout with the police.