When the 35-tower Fort Greene Houses project opened to much fanfare in 1942, it replaced a blighted area near the Brooklyn Navy Yard that was awash in prostitution and crime.

At the time, the vision for the project, the first of its kind anywhere in the world, was as an “austere array of high-rise towers set amidst a field of landscaped lawns.” Its intent was to provide low-rent housing and a strong community for more than 13,000 people.

Success was virtually assured. The project’s architects had designed Rockefeller Center. Its staff included “trained housing assistants” to solve tenant issues. The well-read Brooklyn Eagle newspaper called it “comfortable housing for workmen … streamlined for happy homemaking.”

Almost immediately, similar projects were put into motion throughout the city.

But as Thomas J. Campanella reveals in his comprehensive new history of the borough, “Brooklyn: The Once and Future City” (Princeton University Press), the Fort Greene Houses, doomed by ill-advised government policies, turned sour almost overnight, instead ushering in the concept of the projects — high-rise communities throughout the city that would drown for decades in violence and blight.

Signs of trouble appeared as soon as 1944. A visiting reporter noted broken windows and hallways filled with trash, and that summer saw racial battles, including more than a hundred white teenagers “descending on the project … armed with clubs and baseball bats” to beat up black teens.

Problems were exacerbated when, in 1947, the city declared that only residents making less than $3,000 a year could live there, evicting families that approached higher income.

“Fort Greene’s more prosperous families were a stabilizing force; purging them was like pulling a keystone out of an arch,” Campanella writes. “ ‘Those are the families we need to keep,’ pleaded resident activist Olivette Thompson, ‘the kind we can’t afford to lose.’ ”

As families achieving a measure of success were evicted, the projects became dangerous.

“The rule incentivized inertia, and bent ambition and enterprise toward crime,” Campanella writes. “The result, [according to New York Times writer Harrison Salisbury], was ‘a human catchpool that breeds social ills and requires endless outside assistance.’ ”

In 1949, after six women were victims of rape or attempted rape on the grounds, residents stormed the local police station, begging cops to take action against soaring crime. But the police could do little, since they were barred from entering the complex unless responding to specific calls. The project had its own security guards, but they were “older and poorly trained,” and carried no guns.

The “projects” became one of the worst failed experiments in the history of housing.

“Born of good intentions but ruined by ill-considered policy,” Campanella writes, “the celebrated city-in-a-city became more feared than the infamous jungle it had replaced.”

Campanella’s book does a masterful job of showing how individual egos or ill-planned decisions of long ago set the stage for the city we know today.

He describes how New York’s parks commissioner and power-mad master builder, Robert Moses, destroyed certain neighborhoods and tricked others, only to leave us with the Brooklyn-Queens Expressway.

“For Moses, lacing Gotham with modern parkways linking the metropolis by road to the nation at large was a keystone ambition of his career,” Campanella writes.

After he created the Henry Hudson and Belt parkways, Moses’ premiere goal was the development of a 23-mile motorway called the Brooklyn-Queens Connecting Highway, later changed to the BQE.

But in attempting to create a more accessible city, Moses destroyed thriving neighborhoods, as achieving his highway visions involved “punching through some of the most densely built urban terrain on the Eastern Seaboard.”

Sunset Park, in particular, was decimated by the roadway’s construction.

To build the Gowanus Parkway, which Moses saw as a transitional roadway to the BQE, “hundreds of buildings had to come down on both sides of [Third Avenue],” which had “flourished as the commercial core of Sunset Park’s large Scandinavian neighborhood.”

The parkway doomed the surrounding streets to permanent darkness. Moses then widened the avenue “from four lanes to 10 to handle all the truck traffic generated by the still-busy industrial waterfront.”

“Within a decade,” Campanella writes, “not only Third Avenue — once home to seven movie theaters, scores of shops, stores, restaurants and cafes — but much of Sunset Park would be spiraling toward abandonment and blight. Whatever survived was finished off by the late 1950s, when the Gowanus [Expressway] was widened from four to six lanes.”

For the section of the BQE running through what is now Carroll Gardens, Cobble Hill and Brooklyn Heights, Moses used underhanded tactics, tricking residents to get his way.

The poorer residents of what was then South Brooklyn had little clout to prevent Hicks Street from being converted into the expressway. But wealthier Brooklyn Heights, where Hicks was “lined with mansions,” had that clout, and intended to use it in 1942 to prevent their neighborhood from being similarly invaded.

Residents wrote sharply worded editorials, and the Brooklyn Heights Association campaigned against it to city officials.

But Campanella writes that Moses always knew that taking over Hicks Street in the Heights wouldn’t fly, and floated the possibility as a ruse, guaranteeing that his “compromise” — the less-moneyed Furman Street — would find quick approval.

“There is no evidence that Moses seriously meant to run his road up Hicks Street,” Campanella writes, noting that “given his penchant for grudges,” the rumor might have been Moses’ revenge for Heights residents battling construction of a Brooklyn-Battery Bridge through the neighborhood, as he had proposed years earlier.

“Introducing Furman Street as the substitute made Moses seem to be yielding to community will, while Heights residents convinced themselves their timely action saved the day.”

Campanella also includes a section about the famed desertion by the Brooklyn Dodgers, which he blames on “the mass exodus of Brooklyn’s middle and working classes after World War II.”

Co-owner Walter O’Malley began studying a possible new ballpark to replace the decaying Ebbets Field, the Dodgers’ Flatbush home since 1913, as early as 1946.

“Ebbets Field, already past its expected 30-year life span, was fast becoming a maintenance liability and could barely handle the huge crowds the Dodgers were drawing,” Campanella writes. “Seats were splinter-prone, bathrooms were obsolete, and parking in the surrounding neighborhood was scattered, scarce and costly.”

Given the project’s prestige, the nation’s top architects and designers clamored to help create the team’s new home.

Norman Bel Geddes, the best-known American designer throughout the ’30s and ’40s, proposed a retractable-roof ballpark that would include “rubberized seats, vending machines on every third seat back, [and] an early version of Astroturf . . . which can be painted any color.”

But Bel Geddes and O’Malley clashed and never moved forward with the project.

Geodesic-dome creator Buckminster Fuller was also briefly involved, proposing a dome-like, all-weather structure for a new Dodgers stadium “skinned with translucent fiberglass petals opening and closing to the sky.”

But the Ebbets Field site was too small, and O’Malley couldn’t afford to both buy new land and build a new stadium. He appealed to Moses for urban-renewal funds to buy the land where Barclays Center is today, but Moses refused.

O’Malley struggled for years to track down both a site and the funding, ultimately succeeding in neither. In 1957, seeing no alternative, he announced that the team was moving to Los Angeles.

O’Malley became the most hated man in Brooklyn — a trope of the time called the three worst humans beings to ever live “Hitler, Stalin and Walter O’Malley” — although the 1974 release of Robert Caro’s book “The Power Broker” revealed that Moses played a significant role in the team’s leaving as well.

But Campanella writes that the Dodgers’ sinking attendance even in winning years coincided with Brooklynites’ exodus to suburbia in the 1950s, and that the real culprit was the disintegration of the Dodgers’ fan base.

Dodger attendance fell 33 percent from 1947 to 1956 — “a difference of 800,000 attendees” — despite the team winning four pennants and one World Series title during that time.

“Not even that most elusive of dreams — a Dodger world championship, captured at long last in 1955,” Campanella writes, “would stem the inexorable tide of flight.”