When your small urban yard is about as wide as an SUV is long, crafting a garden space becomes an exercise in ingenuity.

Some people borrow the distant view; others use visual gimmicks such as mirrored walls or trompe l’oeil murals. For neighbors Steve McMaster and Bill Eppard Jr. and their partners, the solution became all about sharing. They connected their two small yards to form one and later added the adjoining back yard of McMaster’s brother and his wife. The result is a single garden of three rowhouse yards in Shaw that has become greater than the sum of its parts.

The spaces retain their own identity but are connected by two gates and a network of paths. The neighbors feel at ease in one another’s landscape and, moreover, revel in the psychological linkage of the spaces.

“I think I’ve got the prettiest view,” said Steve McMaster. “To Bill’s garden, through the moon gate.”

“It really is a nice feeling to be able to go between yards,” said Eppard, “and not be so confined in a such a small space.”

Common landscapes are not uncommon in condos and apartments across the Washington area — the District has many communal rooftop gardens hidden from street level — but it is much harder to find individual homeowners willing to fudge their lot lines.

Eppard and McMaster like that they can go between their houses without using the street. “It’s much more private, and for running around for a cup of coffee, it’s perfect,” said Eppard.

Shared spaces need neighbors who get along, stay put and aren’t territorial. If you need to draw up a contract to make the arrangement work, it’s probably not for you. Eppard’s advice? Think about it. “If you’re good friends and plan to stay put, yeah.”

Now mature and with most of the construction elements done, the gardens have become a place for relaxation and tinkering. The sunny northernmost garden functions as the communal tomato patch, the abundant fruit of the central kiwi vine will end up in everyone’s kitchen, and the respective pets are free range.

“The children, and the dogs and the cats, they made no distinction” between the yards, said Brian McMaster. He and his wife, Kathleen Strouse, have two sons, 11 and 7, who found a small city yard something magically more expansive, ultimately leading to the fish and turtles in the garden of Eppard and his partner, Chuck Fiorentino. This is a horticultural jewel, stuffed with layers of specimen trees, shrubs and potted plants. Eppard, an inveterate plantsman, has raised a collection of choice Japanese maple varieties and has managed to find room for a fish pond with a waterfall and aquatic plantings. The pinnacle plant is a slow-growing weeping blue atlas cedar, now more than two decades old and trained, bonsai-like, into a curtain of blue-gray needles.

The shared arrangement comes into its own during parties. Guests can find a quiet corner to talk or smoke. During one surprise party, they assembled in one garden before entering another.

For these neighbors, the sense of togetherness was reinforced by their common need to fix up their houses.

The late Victorian rowhouses are on Marion Street NW in Shaw . When Eppard and Fiorentino came to the neighborhood in 1986, the homes were affordable for two guys on a budget — Eppard was a flight attendant, Fiorentino in nursing school — but at a cost. Life in Shaw meant navigating a Rhode Island Avenue torn up for years by Metrorail construction and living in a neighborhood then known for its drug dealing and crack houses.

Most nearby residents used their backyard spaces as a sanctuary for their cars, but Eppard was determined to have a garden in an area that was just 17 feet wide and 34 feet deep.

McMaster, who knew Eppard as a friend and colleague, bought the adjoining house five years later. When he came to it, it had signs of being used as a crack house. The yard contained an old silver maple tree and tons of rubble and trash. He carted off 18 truckloads of rubbish before he set about fixing up the house and garden.

Half of the brick wall between the two yards was missing and had been replaced with wooden fence panels. In rebuilding it, Eppard and McMaster decided it just made sense to connect the yards by getting the bricklayer to install an arched opening midway along the party wall. They later built wooden gates that, when closed, form a Chinese moon gate circle with the arch.

As Eppard added to his horticultural extravaganza — containers now occupy every free space — McMaster salvaged old granite curbs, stones and bricks, and set about building and paving his yard.

His brother and sister-in-law purchased the third rowhouse in 1994, when the previous longtime resident died.

Brian McMaster recalls regrading the yard “shovelful by shovelful” to direct rainwater away from the house before putting in paths. With two yards already hooked together, connecting the third was a no-brainer, though the new link needed some thought and serendipity.

The brothers bought some salvaged iron railing and found a blacksmith to form it into an airy gate decorated with small circles that echo the moon gate. They lowered the wooden fence between the properties, from six to little more than three feet, and built an arbor above the gate.

The two gates together form one of three key features that tie the yards together. With their arches and respective canopies of vines and trees, the gates function as something grander: inviting portals between the spaces.

The second element is the seamless network of paths. Though of different materials, they direct circulation through the spaces and create a visual connection.

The third element is the specimen plants that blur the property lines. A mature corkscrew hazel — known to gardeners as a Harry Lauder’s walking stick — has draped itself on one side of the moon gate and both sides of the wall.

Over the other gate, a pair of kiwifruit vines — a male and female for effective fruit set — have formed a colossal green archway festooned in clusters of ripening, orange-brown fruits. They look supermarket-ready in late summer but will take well into October to ripen.

Steve McMaster also planted three strategically placed hardy orange plants, seedlings from his late grandmother’s farm in South Carolina. This cold-tolerant citrus produces fearsome thorns and is grown in the south as a barrier plant and in the north as a novelty. Growing between the gardens and the alley, it functions as both.

Shared yards rely on the owners staying put, unless any newcomers are on the same social wavelength. That is about to be put to the test. Brian McMaster and Kathleen Strouse have moved with their sons, Nat and Elliott, to a larger house elsewhere in Northwest Washington and are reluctantly planning to put the Marion Street rowhouse on the market.

“My hope is [a new owner] will realize the space is more interesting with gates,” said Steve McMaster. If a newcomer wanted the gate permanently closed, “I think I would put some small, low-growing planting in front of it, and keep the gate,” he said.

Eppard added: “Steve and I were saying the other day, we need to find someone we know to buy this house.”

Meanwhile, Eppard is lobbying for one of the hardy oranges to come down so he can plant something new and different. When it comes to gardening in tight spaces, these rowhouse neighbors have come to know that where there’s a wall, there’s a way.

More from Adrian Higgins

Photos: Check out a gallery of the three shared backyards.

How it works: Adrian Higgins breaks down the layout of the space in detail in this illustration.

Read: Two front yards, one shared garden

Live chat:Higgins will chat about the concept of shared yards at noon on Thursday

Video: Higgins talks about reaping the rewards of summer and preparing for fall in a new installment of his series on his community garden plot.

Homegrown: To learn more about planting your own vegetable gardens, go to washingtonpost.com/vegetablegardens.