The 76-year-old senator ran a largely sleepy campaign until the primary on June 3, when he was edged out by Mr. McDaniel but won enough votes to keep his opponent from outright victory. Mr. Cochran, who is seeking his seventh term, used the past three weeks to turn out Democratic voters — especially African-Americans — to make up that deficit.

A surge of voters showed up on Tuesday in African-American precincts and in Mr. Cochran’s other strongholds to surprise Mr. McDaniel, 41, who just Monday night declared his campaign had gone from impossible to improbable to unstoppable. Early Wednesday, with all but one precinct reporting, Mr. Cochran’s lead over Mr. McDaniel was a little more than 6,000 votes. Recounts are not required under Mississippi law, although Mr. McDaniel could seek to challenge the results through the courts.

Mr. Cochran’s victory was powered in part by African-Americans in areas of north Jackson whose turnout shattered that seen in those precincts in the primary. Turnout jumped fivefold at New Hope Baptist Church, and sevenfold at Green Elementary School, where only 14 voters came out on June 3 but about 100 showed up on Tuesday.

Their high numbers came despite pledges by conservative political action committees to monitor turnout in Democratic areas targeted by Mr. Cochran’s campaign. Both the N.A.A.C.P. — which sent its own poll watchers — and the United States Justice Department expressed concerns about the possible intimidation of black Democrats, but no irregularities were reported to Mississippi election officials. The state has no party registration, and anyone could vote in the Republican runoff who had not voted in the Democratic primary, which was won by former Representative Travis Childers, 56.