The result represents a remarkable comeback after his campaign was all but written off following setbacks last summer.
Speaking to supporters in Dallas, Texas, he said the most important part of the campaign now lay ahead, in which he must "make a respectful, determined and convincing case to the American people" to pick him over the Democratic candidate in November.
Mr McCain went on to outline the challenges facing the nation, including the war in Iraq and the fight against al-Qaeda and the Taleban.
He also pledged a campaign that avoided "false promises", and appealed for voters to "stand up and fight for America, for her strength, her ideals and her future".
Mrs Clinton insists she can go all the way to the White House
He will go to the White House on Wednesday for lunch with George W Bush, when he is expected to receive the president's endorsement.
Conceding the race at a rally in Irving, Texas, Mr Huckabee said: "It's now important that we turn our attention not to what could have been or what we wanted to have been but what now must be, and that is a united party."
Both Democratic candidates called Mr McCain to congratulate him on sealing the Republican nomination.
For the Democrats, a total of 370 delegates to the nominating party convention in August were at stake in Tuesday's four races.
The race was still too close to call in Texas, the day's biggest prize with 228 delegates up for grabs, including 67 in caucuses held after the primary vote.
Mr Obama had 1,386 delegates to Mrs Clinton's 1,276 going into Tuesday's contests, the AP calculated. A total of 2,025 is needed to secure the Democratic Party's nomination.
Because delegates are divided proportionally, Mrs Clinton needs landslide victories on Tuesday and beyond to catch up with her rival.
Hillary Clinton 17 states, 1,592 delegates
Arizona, Arkansas, California, Florida, Massachusetts, Michigan, Nevada, New Hampshire, New Jersey, New Mexico, New York, Ohio, Oklahoma, Pennsylvania, Rhode Island, Tennessee, Texas
Barack Obama 24 states, 1,723 delegates
Alabama, Alaska, Colorado, Connecticut, Delaware, Georgia, Hawaii, Idaho, Illinois, Iowa, Kansas, Louisiana, Maine, Maryland, Minnesota, Missouri, Nebraska, North Dakota, South Carolina, Utah, Vermont, Virginia, Washington state, Wisconsin
2,025 delegates needed for nomination. Source AP (includes all kinds of delegates) Q&A: US election delegates
Arizona, California, Connecticut, Delaware, Florida, Illinois, Maryland, Missouri, New Hampshire, New Jersey, New York, Ohio, Oklahoma, Pennsylvania, Rhode Island, South Carolina, Texas, Vermont, Virginia, Washington state, Wisconsin
Mitt Romney 11 states, 251 delegates
Alaska, Colorado, Maine, Massachusetts, Michigan, Minnesota, Montana, Nevada, North Dakota, Wyoming, Utah
1,191 delegates needed for nomination. Source: AP (includes all kinds of delegates)
She told cheering crowds in Columbus, Ohio, that she was determined to stay in the race and looked forward to continuing the debate with Mr Obama "in the weeks ahead".
"For everyone here in Ohio and across America who has ever been counted out but refused to be knocked out, for everyone who has stumbled but stood right back up, and for everyone who works hard and never gives up, this one is for you," she said.
Mrs Clinton also pointed to Ohio's status as a state which had picked the winning presidential nominee in every contest in recent history.
"You know what they say - as Ohio goes, so goes the nation. Well, this nation's coming back and so is this campaign."
Between the nationwide Super Tuesday contests on 5 February and the 4 March polls, Mr Obama won 11 contests in succession, giving him a lead over Mrs Clinton in the delegate count.
Addressing supporters in San Antonio, Texas, Mr Obama congratulated Mrs Clinton on running a "hard-fought race" but pointed out that he still held the advantage.
"No matter what happens tonight, we have nearly the same delegate lead as we did this morning, and we are on our way to winning this nomination," he said.
Mr Obama also used his speech to attack Mr McCain's policies on Iraq, warning that he would lead the country on the same course as Mr Bush had followed.
Mr Obama added that the result from Texas might not be known until Wednesday. He spent twice as much as Mrs Clinton on TV adverts in the state, including some in Spanish.
According to exit polls for the Associated Press news agency, Hispanics cast nearly a third of the election day votes in Texas - up from a quarter in 2004. In previous contests this year, they have favoured Mrs Clinton.
African-American voters - who have heavily supported Mr Obama - accounted for about 20% of the votes cast in Texas, the AP said, about the same as four years ago.
The economy was the most important issue for Democratic voters in all four states, especially Ohio, according to exit polls.
Those polls also suggested Mrs Clinton was doing well among white, blue-collar and older voters in Ohio, which may indicate she has halted Mr Obama's advance into those groups, her core base until recent contests.
Ahead of the day's voting, the New York senator and former first lady played down suggestions she was facing a make-or-break moment.
The BBC's Kevin Connolly, in Ohio's state capital, Columbus, says the struggle between the two senators remains fierce and close, and it is far from certain that America will get the clear outcome from these latest battles that it craves.