AMES, Iowa (Reuters) - Michele Bachmann narrowly won the Iowa straw poll of Republicans on Saturday in the first big test of the 2012 presidential campaign, as Texas Governor Rick Perry formally launched a White House bid that could reshape the race.

Bachmann, a representative from Minnesota, edged out Ron Paul, another representative, and rolled over the rest of the Republican field to capture the nonbinding Iowa mock election, a traditional early gauge of organizational strength in the state that holds the first 2012 nominating contest.

Bachmann won 4,823 votes to Paul's 4,671. Tim Pawlenty, who had focused on a strong showing in the straw poll to rescue his struggling campaign, finished a distant third with 2,293 votes in a bruising setback.

In South Carolina, Perry formally jumped into the race with a blistering attack on President Barack Obama.

"We cannot afford four more years of this rudderless leadership," Perry told a conference of conservatives, promising to reduce taxes, regulations and government intrusion in people's lives.

The straw poll and Perry's campaign launch, coming less than six months before Iowa's nominating contest, promised to reshuffle the Republican field fighting for the nomination to challenge Obama, a Democrat, in 2012.

Perry, a staunch social conservative with a strong job creation record in Texas, is expected to immediately vault into the top tier of contenders along with front-runner former Massachusetts Governor Mitt Romney. Perry visits Iowa on Sunday.

Perry finished sixth in the straw poll with 718 write-in votes even though he was not on the ballot. That was more than Romney, who was on the ballot and received 567 votes even though he did not participate.

Six Republicans had participated in the poll, pleading for support from voters who rolled into the site in dozens of buses and jammed candidate tents for music and free barbecue.

Lines were long at the tents hosted by Pawlenty and Bachmann, who competed for the votes of the social conservatives who dominate the Iowa nominating contest. Supporters of libertarian Paul swarmed the grounds and jammed the arena when he spoke.

Clara Bulens of Grinnell, Iowa, said she traveled to the poll to vote for Bachmann because "she's beautiful, brilliant, very personable and I love her platform."

The poll, a fund-raiser for the state party, created a carnival atmosphere around Iowa State University's basketball arena. Any Iowa resident over 18 could show up and participate, with many allowing a candidate to buy their $30 ticket.

Candidates organized buses to haul in supporters from around the state in a warmup for the organizational effort needed in the Iowa caucuses, scheduled for February 6.

Finishing fourth was former Senator Rick Santorum, with businessman Herman Cain in fifth ahead of Perry.

(Editing by Will Dunham and Vicki Allen)

mochila insert follows