It was nearing last call.
The music was still pounding but the night was drawing to a close at the Pulse nightclub in Orlando when shots rang out.
At first, the crack of gunfire did not really register.
"I thought it was firecrackers," said Ray Rivera, 42, who was working at the club as a DJ. He lowered the reggae song he was playing to get a better listen.
The gunfire did not let up. As round after round was fired early Sunday, people started dropping, some in panic, some because they were wounded, and others because they were dead.
"I saw bodies on the floor, people on the floor everywhere," Rivera said. "It was a chaos, everybody trying to get out."
A man, identified by law enforcement officials as Omar Mateen, had come to the club to kill. And over the course of the next three hours, until he was shot and killed himself, he executed dozens of people.
By the time the shooting ended, it would rank as the deadliest mass shooting in American history. Inside the club, there were 39 dead people along with the gunman, who was killed around 5 a.m. after a shootout with the police.
Nine more people died either at hospitals or on their way to them. Two bodies were discovered on the street just outside the club, according to Mayor Buddy Dyer of Orlando. Fifty-three people were wounded.
Even in a post-Columbine world, where mass shootings have become so frighteningly common that the phrase itself is now a part of the lexicon, the bloody rampage at a small nightclub in Central Florida was shocking not only in its brutality but for the seemingly methodical fashion in which it was carried out.
One out of every three people in the club was either wounded or killed. Some people had to hide for hours, crouched in bathrooms or in hidden corners inside the club, sending frantic text messages to the outside world begging for help. For others, the only way to get out alive was to scramble and crawl over the bodies of the dead.
The mayhem was captured on video taken outside the club moments after the shooting. One group of men, some shirtless, carried a wounded man to a waiting pickup truck to be rushed to the hospital. Another group tried to help a man lying on the pavement, blood pouring from his wounds. A woman, apparently shot, staggered out into the night.
The bloodshed ended only after a daring rescue operation by the police, in which they burst into a room in the club and freed 15 to 25 people before confronting the gunman and freeing another group being held hostage.
As the investigation into the shooting continues, witnesses, the police and local politicians offered a vivid and gruesome portrait of how the carnage played out.
Saturday was Latin Night at the club, which bills itself as "Orlando's Premier Gay Nightclub."
The club is housed in a relatively small building on a street filled with chain restaurants and shopping centers near downtown, roughly 18 miles from Disney World.
The club itself is divided into three separate areas, each with its own theme and music selection. On Saturday, it was a mix of reggaeton, bachata, merengue and salsa. A video taken inside the club in the hours before the attack captured the festive mood, with patrons taking shots, slugging back beers and dancing under neon lights.
Lizbeth Alvarez, 31, who was in the club with her girlfriend, Aixa Soltren, 27, said people often are packed in shoulder to shoulder.
The main dance floor is in a room called "The Jewel Box," where scores of gays, lesbians, transgender people and bisexuals from across Central Florida flock to party.
On Saturday, as on all nights, there was a security guard posted at the front entrance. It was unclear whether Mateen shot his way into the club or smuggled in his weapons - which included an assault rifle, a handgun and lots of ammunition - and then opened fire.
Joel Figueroa, 19, of Orlando, was with his friend, Stanley, dancing when the first shots rang out.
"The only thing I could think of was to duck," he said soon after the shooting, still obviously shaken.
The moments that followed were a blur of panic and confusion. By the door, he saw his friend.
"There was Stanley, on the floor," he said. He was shot three times, but managed to stumble outside, blood pouring from a huge gash in his arm. His condition was unclear.
In those first few frantic minutes, scores of people ran out onto the street, many wounded, as the police rushed to the scene. Word spread quickly, with the wounded texting friends and family.
The club itself posted a message on Facebook shortly after the shooting began: "Everyone get out of pulse and keep running."
One man wrote a text to his mother, saying he was shot and thought he was dying.
Another mother showed reporters the stream of her son's increasingly desperate text messages.
"in bathroom," he wrote at 2:46 a.m. "he has us"
"call the police"
"call them mommy"
"I'm gonna die"
It was unclear whether her son escaped.
Luis Burbano, who gave interviews to several television networks, said that after the initial burst of gunfire there was a momentary pause that he used to "jet for the door."
On his way out, he saw a bartender hiding in a fitting room, "waiting for a miracle" along with other patrons.
After he escaped, a man near him collapsed, his arm badly wounded. Burbano took off his shirt and wrapped it around the man's arm.
He then saw another man with a bullet lodged in his leg, and Burbano used another piece of clothing to try to stem his bleeding.
With bodies littering the floor, at least 30 people remained trapped inside the club, according to the police.
A group of 15 to 25 were huddled in a room "isolated" from the gunman, Dyer told CNN.
Another five to eight people were being held in a room with the gunman.
The police, by now swarming outside, had established communication with Mateen, but it was unclear what they discussed. Heavily armed members of the SWAT team took positions around the building while other emergency medical workers rushed the wounded to a hospital, which was just a block away.
Finally, around 5 a.m., the authorities took action.
They breached the wall of the isolated room with an armored personnel carrier known as a Bearcat.
"That is when the shooter opened the door and started shooting outside," Dyer said.
One officer was shot in the head, but was not seriously wounded because the bullet struck his Kevlar helmet.
More than a dozen law enforcement officers took aim at Mateen, and he was shot and killed.
Next to his body was a battery pack, and the police were concerned that he might have been wearing an explosive device, so they investigated the scene with a robot at first.
It would take another hour before they could start to assess the extent of the damage. As they made their way deeper into the club, the toll grew higher. It would take hours for all the bodies to be removed from the site, even as worried friends and relatives desperately sought information about people they feared might have been inside the club.
Brian Reagan, a manager at the club who was there during the shooting, took to Facebook to try to convey just how overwhelming it was to be caught in the center of a nightmare.
"I am scared, nervous, and concerned for every single person that was in that building," he wrote. "Please pray. This can not be real."