FOUR DAYS before this month's special election in San Diego County to replace imprisoned former Rep. Randy "Duke" Cunningham, Republican strategists back in Washington were worried. In addition to voter discontent with GOP leadership and the looming shadow of scandal dominating the campaign, Democrats appeared to enjoy yet another advantage: More absentee ballots were being submitted by Democratic voters than by Republicans.

The advantage did not last long. Jolted to life, the GOP machinery revved into high gear as activists poured into the district. They scoured the party's computer database for sympathetic voters who had requested absentee ballots but had not yet submitted them, knocked on their doors and called them on the phone. Suddenly, thousands of additional votes had been secured, and by election day, the GOP had turned around a costly deficit — with 10,000 more Republicans than Democrats voting absentee.

That final flurry of absentees, along with other forms of voter targeting, contributed to a surprising GOP victory that cut through the heart of the Democrats' broader 2006 election strategy. Rather than using Cunningham's criminal role in a lobbying scandal to turn the special election into a preview of how they could translate a "culture of corruption" into a national revolution in November, Democrats watched in disappointment as a Republican lobbyist won the race — and as the Democratic candidate performed barely better than presidential nominee John Kerry had in that same district two years before.

The results in the 50th Congressional District did not merely illustrate the potential inadequacy of the Democratic strategy for the November elections; they foreshadowed a much bigger and more startling story line: That even in the face of Republican scandals, sour approval ratings, the aftermath of Hurricane Katrina and growing public rejection of President Bush's policies in Iraq, the Republican Party still holds the lead in the art and science of obtaining power — and keeping it.

The fact is that over two or three decades, the GOP has painstakingly built up a series of structural advantages that make the party increasingly difficult to beat. And in the last five years, it has strengthened its hold under President Bush and his political guru, Karl Rove.

Democrats need a net gain of 15 seats in the House and six in the Senate to take power. And Republicans may well suffer some setbacks. But if the GOP retains control of Congress despite such a gloomy political climate — or even if it keeps control of just one chamber and narrowly loses the other — party leaders can rightfully argue that their long-term goal of constructing a lasting political majority remains viable.

The Republican fortress has many underpinnings, such as gerrymandered congressional districts that favor the GOP, an intellectual infrastructure that churns ideas through conservative think tanks and media, an ever-stronger political and policy-based alliance with corporate America, and the most sophisticated vote-tracking technology around.

Some of the GOP advantages are recent developments, such as the database called Voter Vault, which was used to precision in the San Diego County special election. The program allows ground-level party activists to track voters by personal hobbies, professional interests, geography — even by their favorite brands of toothpaste and soda and which gym they belong to.

Both parties can identify voters by precinct, address, party affiliation and, often, their views on hot-button issues. Democrats also use marketing data, but Voter Vault includes far more information culled from marketing sources — including retailers, magazine subscription services, even auto dealers — giving Republicans a high-tech edge in the kind of grass-roots politics that has long been the touchstone of Democratic activists.

As a result, Republicans have moved well ahead of Democrats nationally in their ability to find previously unaffiliated voters or even wavering Democrats and to target them with specially tailored messages. Voter Vault, although it is a closely guarded GOP trade secret, is nevertheless easily accessible to on-the-ground campaign workers and operatives should they need to mobilize votes in a hurry.

One suburban African American woman in Ohio, for example, told us that though she tends to vote Democratic, she was deluged in 2004 with calls, e-mail messages and other forms of communication by Republicans who somehow knew that she was a mother with children in private schools, an active church attendee, an abortion opponent and a golfer.

The database was honed and expanded after the 2000 election recount, when strategists such as Rove and Republican National Committee Chairman Ken Mehlman vowed that they would never again permit Democrats to outperform the GOP in a national campaign. Mehlman, who worked in Bush's first term as White House political director, used the months following the recount to study the Democrats' get-out-the-vote efforts. "It was like they had all the planes and the bombers, and we had horses," Mehlman said, referring to the Democrats' once-superior ability to harness labor union activists and other liberal groups to reach voters and get them to the polls.

The new-and-improved GOP database helped Republicans begin to peel away select pieces of the old Democratic base, such as politically conservative and pro-Israel Jews, as well as socially conservative blacks, Latinos and blue-collar workers. In Cleveland, Republicans in 2004 compiled a list of Russian-speaking Jewish immigrants who they knew backed Bush's stance against Islamic terrorism, then organized a rally entirely in Russian on the Sunday before the election.

Bush and other Republicans have also sought support from highly influential African American pastors, who are gaining power in swaying votes. The courtship of the pastors has come in part through a special office in the White House devoted to funneling government money to church-based social service organizations — a program that has drawn enthusiastic support from black churches that have, in turn, provided GOP candidates entree into terrain long dominated by Democrats.

Although Bush's national performance among blacks did not increase by much between 2000 and 2004, there were significant increases in key areas. In Ohio, a 7-percentage-point rise among black voters for Bush created the cushion he needed to carry that pivotal state and secure reelection.

Perhaps more than any other administration, the White House of George W. Bush has mastered the art of mixing politics and policy and keeping track of how federal government decisions can affect even obscure local elections. Rove, with a broad portfolio and extraordinary influence, introduced a new political doctrine, effectively putting the federal bureaucracy and the bully pulpit of the White House in the service of GOP political ends.

All administrations are political, of course. But never before has the White House inserted electoral priorities into Cabinet agencies with such regularity and deliberation. Before the 2002 midterm elections, for instance, Rove or Mehlman visited with the managers of many federal agencies to share polling information and discuss how policy decisions might affect key races.

In 2002, Rove told Interior Department officials of the importance of helping farmers in Oregon whose political support was crucial to Gordon Smith, a vulnerable Republican senator. Within months, perhaps because of Rove's exhortations, the agency did just that, supporting the diversion of water from the environmentally important Klamath River for the sake of irrigating farmland. Thousands of salmon eventually died in the newly shallow waters. But the senator secured his reelection.

Other pieces of the plan preceded Bush and Rove. The legendary political genius Lee Atwater masterminded a long-term campaign to redraw congressional district lines, which has given Republicans a long-term edge in House elections that is difficult to reverse.

Some Democrats unwittingly lent a helping hand to this strategy. Incumbent Democratic members of Congress, along with African American and Latino politicians at the local level, put their party at risk by cooperating in the early 1990s with Republican efforts to redraw the boundaries of electoral districts across the country. Individual Democrats and black and Latino politicians benefited by winning elections, but the overall result was a stronger Republican grip on legislative seats at all levels. With Democratic voters packed into urban minority districts, adjacent suburban and exurban districts sent more white conservatives to Washington.

These changes, along with gerrymandering by both parties on the state level, were so pervasive that they left only about two dozen of the 435 seats in the House competitive in any typical election.

This year's elections are only one test of the Republicans' long-term plan to transform American politics. Unless Democrats eliminate these structural and strategic deficits, the GOP will continue to govern what has become, in effect, a one-party country.