McDaniel had narrowly led Cochran in the primary three weeks ago but failed to get the required 50% to avert a runoff. But in the end, the populist firebrand who tapped into Mississippi's conservative culture and upended establishment politics fell short.
With 99% of precincts reporting, Cochran had 51% to McDaniel's 49%, according to the Associated Press.
The race was among the most costly and hard-edged of the midterm primary election cycle, pitting the GOP establishment against the tea party in all-out political warfare -- one that, at least in its the final days, took on racial overtones. More than $17 million was spent in the poor state.
The six-term senator's ability to eke out victory came as a surprise because he had appeared unable to counter the swell of antiestablishment frustration in Washington.
Late outreach by Cochran's team to Democrats, particularly African Americans who tend not to vote for Republicans, may have boosted his showing, along with Cochran's core argument that his seniority in the Senate promised a continued flow of federal resources to Mississippi.
McDaniel, a charismatic two-term state senator, had drawn widespread support with his message of economic populism and a nostalgic promise that Mississippi's better days were not all past, forcing the veteran senator into the runoff.
"While people act like this is some tea party versus the establishment, what it is is an incumbent versus people who don't like Washington," Joe Nosef, chairman of the state Republican Party, said before the votes were tallied.
The outcome of the rough race all but ensures a tough general election battle ahead, as Democrats believe they may have an opening in the red state with the conservative-leaning Travis Childers, a former congressman.