The police had received more than 5,000 tips concerning the case, Chief Dugan said, but the breakthrough came Tuesday afternoon, when Mr. Donaldson asked the manager of the McDonald’s restaurant where he worked to hold a bag for him, and walked out. The manager looked in the bag, saw a semiautomatic pistol, and alerted a police officer who happened to be sitting in the restaurant, in the Ybor City neighborhood.

The officer notified her superiors, who sent detectives to the restaurant. Mr. Donaldson returned a short time later, was questioned, and then was arrested.

“The gun is what we needed,” Chief Dugan said. “That firearm was used in all four murders.”

The ordeal began on Oct. 9, when Benjamin Mitchell, 22, was shot at a bus stop. Monica Hoffa, 32, was found dead four days later in a vacant lot. On Oct. 19, Anthony Naiboa, 20, was shot a block away from the site of Mr. Mitchell’s killing. Then almost a month passed with no similar killings, until Nov. 14, when Ronald Felton, 60, was fatally shot less than half a mile from where Ms. Hoffa died.

More than seven weeks elapsed between Mr. Mitchell’s death and the arrest on Tuesday, and Chief Dugan said that throughout that time, the investigators on the case met daily and reminded one another of how many days had gone by.