President Obama stirred a crowd of about 3,000 people into a frenzy on Thursday evening during a campaign rally for Democratic gubernatorial candidate Mike Michaud in Portland.

The president began by telling the audience how much he loves Maine, then quickly shifted to stressing the importance of voting next week, of making change and of electing Michaud.

“You have a chance to choose a governor who puts you first,” Obama said. “Republicans are patriots but they’ve got some bad ideas. We know those ideas don’t work.

“Mike’s got a different vision for what the future looks like and I think most of you do, too,” Obama said.

It was a rousing, at-times inspirational speech reminiscent of Obama’s campaign speeches when he ran for president in 2008 and again in 2012. He urged the people in the Portland Exposition Building to reject cynicism and said that, despite what they hear, “America is making progress.”

Just five days before Election Day, Michaud is in a close race with Republican Gov. Paul LePage, with independent Eliot Cutler running a distant third in the latest polls.

Obama is the latest – and last – nationally prominent Democrat to campaign for Michaud this fall.

Previously, first lady Michelle Obama, former President Bill Clinton and former U.S. senator, secretary of state and likely 2016 presidential candidate Hillary Clinton have appeared on stage with Michaud.

The visits by the Obamas and Clintons, and other prominent Democrats, are designed more to motivate the Democratic base and ensure that those voters show up on Election Day than to sway independent voters.

The Portland Expo was packed well before Thursday’s speech and hundreds more supporters stood outside, along with a few protesters. The Michaud campaign said more than 7,000 people had requested tickets to the event.

Michaud had the task of speaking just before Obama. The six-term congressman and former mill worker from Millinocket was greeted with sustained cheers and chants of “We Like Mike,” as John Mellencamp’s “Small Town” played over the speakers.

He addressed the audience warmly and told them he needed their support.

“This is your state and in five more days, you can take it back,” he said, adding later, “Our vision is a vision where we all get to succeed.”

Michaud then went after LePage, using similar language to what he said during a debate this month about the governor being “the best politician I’ve ever seen because he’s knows how to use issues, like welfare and immigration, to divide us and play off our fears.”

According to a recent University of New Hampshire Survey Center poll commissioned by the Portland Press Herald, Obama’s approval rating in Maine is just 39 percent. However, among voters who identify as Democrats, the president’s approval rating is 75 percent.

Those who attended Thursday’s event certainly soaked up Obama’s message.

During a portion of his speech that was directed at women, he talked about Republicans voting against the Fair Pay Act. Many in the audience booed.

“Don’t boo, vote,” Obama shot back. “This is a solvable problem.”

His 25-minute speech hit on familiar Democratic themes, including raising the minimum wage, expanding Medicaid and investing in education. Later, he told the audience that simply voting next week is not enough.

“If you’ve come to this rally, you’re probably going to vote,” he said. “You can’t stop at voting, you’ve got to get involved. Talk to your neighbors … Knock on some doors for Mike.”

Michaud’s campaign received an unexpected boost on Wednesday morning when independent candidate Cutler, who has been running a distant third in public polls, announced to supporters that they should vote for someone else if they don’t think he can win.

Wednesday afternoon, U.S. Sen. Angus King, who had endorsed Cutler in August, sent out a statement saying that he was switching his support to Michaud.

Cutler has stressed that he’s not dropping out of the race, but by Thursday afternoon, his campaign had begun pulling some television advertisements.

Several speakers preceded Michaud and Obama on Thursday, all of whom did their part to energize the crowd.

Portland Mayor Michael Brennan talked about electing a governor, in Michaud, who would work to raise the minimum wage and make Medicaid expansion a top priority.

Maine Democratic Party Chairman Ben Grant talked about the sophisticated get-out-the-vote efforts the party launched about 18 months ago. He said that could end up being the difference on Election Day.

“Are you ready to finish the job?” Grant asked the crowd, which responded with raucous applause.

Democrat Shenna Bellows, who is challenging three-term U.S. Sen. Susan Collins, told the crowd that “working people need a voice in Washington.” She said the election is a contest between “hope and fear.”

Of Michaud, Bellows said, “He’s honest. He does the right thing even when no one is watching.”

U.S. Rep. Chellie Pingree, who served in the U.S. House for six years with Michaud and is all but assured of being re-elected, touted Michaud’s hard work.

“We all know this is a tough campaign. We have five days to go and we can’t take anything for granted,” she said.

Pingree also leveled criticism at LePage, calling him embarrassing and reminding the audience of some of the governor’s controversial statements.

“All too often I have heard people say, ‘Did your governor really say that?’ ” she said.

Former U.S. Sen. George Mitchell spoke just before Michaud, talking mostly about Obama’s economic accomplishments and the shared ideals of Democrats, before turning attention to Michaud.

“Mike knows how to bring people of different views together to hammer out solutions that are broadly acceptable,” Mitchell said, adding that he would restore a much-needed “bipartisan spirit” to the governor’s office.​

Before appearing at the rally, Obama attended a private fundraiser at the home of Robert C.S. Monks and Bonnie Porta in Cape Elizabeth. About 25 supporters, who paid at least $16,200 each, attended the gathering, said an official with the Democratic National Committee.

Porta was a co-chair of the Obama Victory Fund in Maine and previously hosted a fundraiser with Michelle Obama in 2012.

Monks is a board member of MaineToday Media, which owns the Portland Press Herald/Maine Sunday Telegram, the Kennebec Journal and the Morning Sentinel.