WASHINGTON — Rick Santorum won the Kansas caucuses in a rout on Saturday and Republican presidential front-runner Mitt Romney countered in Wyoming, a weekend prelude to suddenly pivotal Southern primary showdowns in the week ahead.
‘‘Things have an amazing way of working out,’’ Santorum told supporters in Missouri, where he traced his campaign through a series of highs and lows. He called his showing in Kansas a ‘‘comfortable win’’ that would give him the vast majority of the 40 delegates at stake.
Final returns in Kansas showed Santorum with 51 percent support, far outpacing Romney, who had 21 percent. Newt Gingrich had 14 percent and Ron Paul trailed with 13 percent.
Santorum picked up 33 of the state’s 40 delegates at stake, cutting slightly into Romney’s overwhelming’s advantage.
In Wyoming, Romney won seven of the 12 delegates at stake, Santorum three, Paul one. Uncommitted also won one.
The day’s events unfolded as the candidates pointed toward Tuesday’s primaries in Alabama and Mississippi that loom as unexpectedly important in the race to pick an opponent to President Barack Obama in the fall.
Polls show a close race in both states, particularly Alabama, where Romney, Gingrich and Santorum all added to their television advertising overnight for the race’s final days.
Gingrich, struggling for survival in the race, can ill afford a loss in either Mississippi or Alabama. Romney is seeking a Southern breakthrough to demonstrate an ability to win the support of evangelical voters.
For his part, Santorum hopes to knock Gingrich out of the race and finally emerge as Romney’s sole challenger from the right.
The contests in Kansas and Wyoming left Romney with 454 delegates in the AP’s count, more than all his rivals combined. Santorum had 217, while Gingrich had 107 and Paul had 47.Romney’s totals included 22 that he picked up in the Virgin Islands, Guam and the Northern Mariana Islands.
A candidate must win 1,144 to clinch the Republican presidential nomination at the national convention in Tampa next August.
Kansas and Wyoming caucuses had little in common except a shared date on the campaign calendar.Romney made a stop in sparsely populated Wyoming last summer.
Kansas drew more attention from the White House hopefuls, but not much more, given its position midway between Super Tuesday and potentially pivotal primaries next Tuesday in Mississippi and Alabama.
Romney left Kansas to his rivals, while Gingrich scrubbed a scheduled campaign trip to concentrate on the South.
Paul and Santorum both campaigned in the state on Friday, and Gov. Sam Brownback appeared with each, without making an endorsement.
In Topeka, Paul told an audience of about 500 that Kansas should be a ‘‘fertile field’’ for his libertarian-leaning views but declined to say how many delegates he hoped to gain.
Santorum, who hopes to drive Gingrich from the race in the coming week, lashed out at Obama and Romney simultaneously in remarks in the Kansas capital city.
‘‘We already have one president who doesn’t tell the truth to the American people. We don’t need another,’’ he said.
The former Pennsylvania senator told reporters he was confident ‘‘that we can win Kansas on Saturday and come into Alabama and Mississippi, and this race should come down to two people.’’
An aide to Gingrich said earlier in the week that the former House speaker must win both Southern primaries to justify continuing in the campaign.
But Gingrich strongly suggested otherwise on Friday as polls showed a tight three-way contest in Alabama.
‘‘I think there’s a fair chance we'll win,’’ he told The Associated Press about the contests in Alabama and Mississippi. ‘‘But I just want to set this to rest once and for all. We’re going to Tampa.’’
Romney had no campaign appearances Saturday. The former Massachusetts governor won six of 10 Super Tuesday states earlier in the week, and hopes for a Southern breakthrough in Alabama on Tuesday after earlier losing South Carolina and Georgia to Gingrich.Associated Press reporters Stephen Ohlemacher in Washington, Thomas Beaumont in Alabama and Phil Elliott, John Hanna and John Milburn in Kansas, and David Lieb in Missouri contributed to this report.