WASHINGTON – When San Francisco Rep. Nancy Pelosi ascended to speaker of the House 18 months ago, liberals cheered. Now some jeer, calling her a traitor to her principles.

In just the past two weeks, this former opponent of the Iraq war negotiated a deal to fund it for one more year. Then, this longtime defender of civil liberties compromised on a surveillance bill critics say covers up illegal wiretapping by the Bush administration and telecom companies.

“You’d have to really think your constituents were stone-cold stupid to count that a victory,” fumed liberal blogger Michael Lazzaro, known as Hunter on Daily Kos, about the surveillance deal.

But in an illustration of the intricate balancing act of politics, some of the very moves that have sparked liberal ire across the country are drawing a quite different reaction in the nation’s capitol. Pelosi, once deemed by conservatives as a shrill and impractical outsider, is now being seen as a clever pragmatist positioning her party for success at the polls – and with the next president.

“She’s a pretty canny politician and knows how to limit risks by cutting deals,” said John Feehery, a Republican Party strategist who was spokesman for Pelosi’s predecessor, Dennis Hastert.

“In her heart of hearts, you know she hated that (surveillance) deal, but she had to get something done,” he added. “She knows you live to fight another day.”

Pelosi herself is quite aware of the tightrope she walks.

At a recent breakfast with reporters, she admitted the surveillance compromise “was a cause for great anger.” She is also regularly reminded how her Iraq war efforts are being received: At various times over the past year a dozen or more anti-war protesters have camped outside her Pacific Heights home.

A closer look at the surveillance and Iraq funding issues makes clear just how Pelosi works her compromises – and what she gets in return.

Pelosi said she didn’t like the provision of the surveillance deal that effectively grants retroactive immunity to telecoms from lawsuits about how they wiretapped customers after the Sept. 11, 2001, attacks.

But despite those concerns, she guided the surveillance bill through the House – allowing it to move even though more House Democrats voted against the bill (128) than for it (105), and Republicans had to muster the votes for victory. That’s a turnabout: In past years, when the GOP controlled the house, Republican speakers regularly blocked legislation opposed by a majority of their party.

Iraq war funding

“The fact is, we had to have a bill, and we couldn’t do better, given the hand that was dealt us,” Pelosi said.

Pelosi took a somewhat different tack this year on Iraq. Changing course on the war was Pelosi’s “highest priority” when she took over House leadership in January 2007, but she ran into presidential vetoes and veto threats – and Congress fell far short of the votes needed to override.

So this year Pelosi let the funding legislation proceed, but attached to it a GI bill, initially opposed by the White House, that greatly expands veterans’ benefits. Bush signed the bill Monday.

The increase in veterans’ benefits was “a shrewd move because the Democrats can portray themselves as pro-military” on the campaign trail, said Julian Zelizer, who has written several books on Congress. Zelizer said the wiretapping deal should also help Democrats running in competitive districts.

Rep. Anna Eshoo, a Palo Alto Democrat and friend of the speaker, put Pelosi’s strategy more succinctly: “She knows when to hold ’em and when to fold ’em.”

Eshoo’s comments underscore an important part of Pelosi’s success: At least this year she has been able to guide her diverse majority without a lot of destructive, internal bickering. John Farrell, author of a biography of former Speaker Tip O’Neill, said one reason is that many of the liberal leaders in the House – not just Pelosi but also Massachusetts Reps. Barney Frank and Ed Markey and Charles Rangel of New York – have learned from past defeats.

“They went through the experience of losing power,” Farrell said. “Now they’re older and more pragmatic.”

But pragmatism only goes so far. When she came to power, Pelosi and other Democrats underestimated Bush’s commitment to the war and the high hurdle posed by the Senate’s 60-vote threshold to pass a bill, said Bruce Cain, who heads the University of California Washington Center. The result has been deadlock on many issues.

No excuses

Pelosi isn’t making excuses.

“I know voters want results on energy and health care. They don’t want to hear about how hard it is to get 60 votes in the Senate,” Pelosi told reporters.

But in 2008, the most important votes for Pelosi are not the ones taking place on the House floor.

Democrats have added to their House majority by winning special elections with “Blue Dog” moderate candidates backed by Pelosi.

But liberal activists aren’t sure that an expanded majority is worth the cost.

“What the Democratic leadership is saying is quite clear: We will continue to trample on the Constitution and support endless expansions of the surveillance state because that is how we’ll win in swing districts and expand our majority,” activist Glenn Greenwald wrote in his blog.

With Congress in session only six more weeks before the election, Pelosi said she will focus on energy costs and housing foreclosures while trying to wrap up the budget bills, and shelve everything else until 2009. Her calculation: a President Obama and an expanded Democratic majority will make next year more productive.

In August, Pelosi will take on another important role, chairing the Democratic National Convention in Denver. During the hard-fought race between Sens. Barack Obama and Hillary Clinton, Pelosi occasionally rebuked backers of both candidates when their attacks went too far.

“We are all very passionate about our politics and the issues we believe in, but we have to be very dispassionate about how we approach winning,” she said in March.

At the time, she was talking about the presidential race. But Pelosi could have been talking about how she has learned to play the game of politics.