By defeating 33-year-old Cory Booker, the 66-year-old mayor will get another four years to lead New Jersey's largest city as it sheds its national image as a community blighted beyond hope.
With 99 percent of precincts reporting, James had 28,363 votes, or 53 percent, and Booker had 24,869 votes, or 46 percent.
Addressing supporters in a Newark hotel ballroom, James said in a short victory speech, "Give glory to God!" and "I want to give glory to the citizens of Newark who made their voices heard tonight."
Hundreds of James supporters hugged each other and cried "Four more years!" in a hotel ballroom filled with red, white and blue balloons and signs bearing the mayor's re-election slogan: "The Real Deal."
"We must come together to continue to rebuild our city," James said. "This election was not about Sharpe James. It's about the future of Newark. Tomorrow we go forward as a family."
The campaign pitted Booker, a newcomer groomed at Ivy League schools, against the seasoned James, who entered Newark politics in the wake of the city's 1967 riots.
James, a state senator and former schoolteacher, garnered support from old guard labor and police unions as well as Gov. James McGreevey and civil rights leader Rev. Al Sharpton.
About 300 supporters chanted "Cory, Cory" as Booker conceded near his headquarters. Booker, a Rhodes Scholar at Oxford who moved to Newark in 1997 and was then elected a city councilman, is out of a job next month when his first City Council term expires.
He is vowing to run for mayor again in four years.
"We fought one hell of a fight," Booker said. "We fought for our values, for our children and for what we believe in."
The months-long campaign was so nasty that federal prosecutors posted observers at the polls to watch for fraud and intimidation.
U.S. Attorney Chris Christie said there were dozens of complaints, but no reports of people being prevented from voting. Police arrested a 25-year-old cousin of Gov. James McGreevey's wife for allegedly vandalizing James' campaign signs. Booker called the arrest "purely political."
The tense election capped a campaign that had drawn national attention and outside money as James and Booker offered starkly different visions of Newark's future.
While both men are black Democrats in a mostly black city, the lighter-skinned Booker said James questioned his black authenticity by calling him a "white boy" and accusing him of taking campaign donations from the Ku Klux Klan.
James spokesman Rich McGrath called the allegations "ludicrous" and said Booker was trying to distract voters from the issues.
A cartoon on the mayor's Web site portrayed Booker on an assembly line behind black Republicans like Supreme Court Justice Clarence Thomas and national security adviser Condoleezza Rice, under the headline "Neo-Black Politicos."
The candidates accused each other of breaking into their campaign headquarters, and a James aide at one point got into a shoving match with a documentary filmmaker James said worked for Booker. A federal judge also found that city officials selectively enforced a sign ordinance to take down Booker campaign posters.
James, who was raised in the city and graduated from nearby Montclair State College, was first elected to the City Council three years after race riots in 1967 devastated this city of 274,000. He was first elected mayor in 1986.
James has taken credit for a 50 percent drop in crime, the demolition of some of the worst public housing projects in the country and a downtown renaissance that has attracted telecommunications companies and brought suburbanites out at night to restaurants and the 5-year-old New Jersey Performing Arts Center. He has also helped lead a push for a sports arena downtown.
The mayor called his opponent an interloper who moved to Newark just five years ago from the privileged northern New Jersey suburbs.
Booker holds degrees from Stanford and Yale Law School and was a Rhodes scholar at Oxford. He made headlines for his hunger strike outside a drug-infested housing project and for living temporarily in a trailer in some of the city's worst neighborhoods.
Booker said James has ignored much of the city in favor of downtown. One-third of Newark's residents live in poverty, and the school system has been under state control for the past six years.
In Paterson, City Councilman Jose Torres became the city's first Hispanic mayor as voters ousted Republican incumbent Martin Barnes, who faces a corruption trial in July for allegedly accepting cash, a swimming pool and even girlfriends from people seeking business with the city.
The election was held under the watch of election monitors appointed in 1999 after a lawsuit alleging Hispanics were being intimidated and denied bilingual service.
In Trenton, Douglas H. Palmer, the first black mayor of New Jersey's capital, easily won re-election to a fourth term.