"The real work starts now," Bing said to loud cheers during his victory speech.
"What we will bring ... is efficiency, transparency, honesty and integrity back to the mayor's office," he said.
With 100 percent of precincts reporting, Bing had 52.3 percent of the vote, or 49,054 votes, to 47.7 percent, or 44,770 votes, for Cockrel. Both are Democrats.
Bing, 65, will be mayor through 2009, serving the balance of the term that belonged to Democrat Kwame Kilpatrick, who resigned in September and went to jail after admitting he lied during a civil trial to cover up an affair with his chief of staff.
Bing must run again in the regular Aug. 4 nonpartisan primary and win the Nov. 3 general election to hold the mayor's seat for a full four years.
The founder of steel manufacturer The Bing Group announced his run for mayor the day after Kilpatrick stepped down as part of pleas to two criminal cases.
Cockrel, 43, was City Council president before Kilpatrick's departure automatically promoted him to the mayor's office. He'll go back to that job now.
"You have not seen the last of me," Cockrel told supporters to cheers and chants of "Run Ken run!"
Shortly after the speech, Cockrel spokesman Daniel Cherrin said he expected a decision in a few days on whether or not Cockrel will run again in the upcoming primary.
In other races around the country, the indicted mayor of Jackson, Miss., was taken from his home in an ambulance Tuesday, just before losing his bid for re-election in a contentious Democratic primary.
Mayor Frank Melton, a 60-year-old who has a history of heart problems, was resting in a Jackson hospital, said his attorney, John Reeves. Melton faces a federal trial next week related to a sledgehammer attack on a duplex in 2006 that he considered a crackhouse.
Harvey Johnson, the former mayor Melton unseated in 2005, and city Councilman Marshand Crisler advanced to a May 19 runoff.
In Alaska's biggest city, Anchorage residents were deciding their next mayor in a run-off election betweeen former state lawmaker Eric Croft and former assembly member Dan Sullivan.
In Detroit, Bing praised Cockrel for running "a hard-fought campaign" and said he looked forward to working together when Cockrel returns to the council.
About 15 percent of the city's registered voters participated. A proposal to revise the city charter also was on the ballot and passed overwhelmingly.
"I don't like either one; it's like tossing a coin. But I'll give Bing a chance," Bonnie Brookslee, 78, said after voting at King High School, east of downtown. "Cockrel went along too much with Kwame when he was on the council."
Bing said earlier Tuesday he would release the names of about 31 people ready to join his team after a board of canvassers certifies vote totals. Prominent names are on that list, Bing said.
Canvassers have 14 days to certify the totals, but it's more likely certification will be complete in about 10 days, elections director Daniel Baxter said Monday.
Scandal caused the special election, which cost $2.5 million including the Feb. 24 primary, but Detroit has other issues on its plate. The city has a $250 million to $300 million budget deficit, double-digit unemployment and a wave of home foreclosures.
The Rev. Jesse Jackson said Bing would bring business acumen and credibility to Detroit.
"When he played basketball he thrilled us. When he moved into business he hired us. Now he will lead us," the civil rights leader said during a telephone interview.
Bing was the No. 2 overall pick by the Pistons in 1966 out of Syracuse. He played in Detroit until he was traded in 1975 and is a member of professional basketball's Hall of Fame.
His Bing Steel company opened in Detroit in 1980, and The Bing Group is a manufacturer and supplier to the auto industry that employs about 500 workers.
He had supported Kilpatrick, but grew disenchanted by the sex scandal that drove Kilpatrick from office and the lethargy that followed at City Hall.
Cockrel was elected in 2005 to his third term on the Detroit City Council and was elevated to president after receiving the most votes.
He moved up to the mayor's office on Sept. 19 and found evidence of fiscal mismanagement and incomplete financial records. He announced the city's deficit could be as high as $250 million.
Bing overcame criticism about his sudden move from suburban Oakland County to an apartment near downtown Detroit to run for mayor.
He also was on the hot seat when he acknowledged he was "not correct" when he claimed to have earned a master's degree in business administration. A comment made on a videotape touting education and staying in school on the National Basketball Retired Players Association Web site was meant to be interpreted in a different manner, Bing told The Associated Press in March.
Bing also said he didn't receive his bachelor's degree in 1966 from Syracuse as he claimed. The economics degree actually was awarded in 1995 after Bing completed lost coursework.