For the past five years, the remaining members of several Episcopal congregations in Northern Virginia have been worshiping in borrowed basements and empty houses while praying to return to the prominent sanctuaries where they married, baptized their children and buried their parents.

Now, after a prolonged and bitter legal battle with former members who broke away and took with them more than $40 million worth of church property, the Episcopal Church and the members who stayed with the denomination are on the verge of taking back their buildings, which include some the faith’s largest, most prominent churches in the region.

After a judge’s ruling last month in favor of the Episcopal Church, settlement talks are underway for a massive property swap that would bring to an end the most expensive litigation — and perhaps the most watched — in Episcopal Church history. While the breakaway congregations still can appeal, both sides said they are trying to work out the details of the property turnover.

“Everyone is moving on the assumption that they need to be prepared to move,” said Scott Ward, attorney for the Falls Church congregants who broke away.

The two sides are so close to a settlement that the Falls Church members who remained with the Episcopal Church and have been meeting in a Presbyterian church basement across the street are planning Easter services back in their old church, a large, historic property. Members of St. Stephen’s Episcopal in tiny Heathsville on the Northern Neck are mapping out the prayers they will say and the music they will play as they march down the street to reclaim their building.

The bishop of Virginia’s Episcopal diocese, the country’s largest, laid out a plan in his annual address late last month to reclaim the church buildings. He called the plan Dayspring, a scriptural reference to a new day, which he believes is upon the diocese.

“It is not overstating the case to say that this is one of the most defining moments in all of our 400-year history,” Bishop Shannon Johnston said.

When the conservative congregations voted to leave the Episcopal Church in late 2006 and early 2007, the case drew worldwide attention. The breakaway members said the denomination had grown too liberal in its theology, and they objected to its ordaining gay clergy and celebrating same-sex relationships, among other things. They chose to become part of the booming, conservative Anglican Church of Nigeria, a separate branch of worldwide Anglicanism. The Episcopal Church is the American branch.

The vast majority of the members who belonged to the old congregations chose to split with the Episcopal Church. Lawyers representing the breakaway groups argued in court that they had legal claim to the properties. In the early months after the split, the conservatives threatened to have Episcopal priests arrested if they set foot on the properties.

Meanwhile, Episcopal blogs across the country slammed the conservatives for joining forces with a Ni­ger­ian bishop who is an outspoken opponent of gay relationships.

Last month, Fairfax County Circuit Court Judge Randy Bellows sided with the Episcopal Church in a ruling that cited Virginia real estate law. In his 113-page opinion, Bellows said the deeds and other documents show the properties belong to the Episcopal Church. He ordered the seven breakaway congregations to leave every single dollar and item that existed before the split to the denomination.

The breakaway congregations are now accounting for prayer books, robes and artwork and preparing to leave centrally located, sprawling complexes for the likelihood of a rented high school gym. The future is in limbo for four preschools that operated in the buildings.

As the thousands of conservative members prepare to vacate churches where they also have strong ties, members said their relocation plan is taken from a Bible verse that commands: “Do not be afraid; do not be discouraged, for the Lord your God will be with you wherever you go.”

Carol Jackson, a lay leader at the Falls Church congregation aligned with the Church of Nigeria, said she and her fellow members are trying to view the court loss through a divine lens.

“We’re all here because God wants us to be. In a secular world those aren’t very wise words, but that’s what we think is true,” she said.

Meanwhile, the Episcopal members who had left their old pews after the votes are eagerly anticipating their return to houses of worship that hold special meaning.

“All three of my children were baptized there,” said Deborah Miller, a 59-year-old nurse who joined the original Falls Church congregation in 1982 and stayed with the Episcopal group. “I buried my dad there. We’ve been to funerals of dear friends there. I have shed so many tears in that building, for joy and for sorrow. It’s within the fabric of who we are. It’s a holy place.”

Although the case appears close to resolution, the damage to relationships among family members and friends who grew up in the same congregation but chose different sides is evident, members said.

“We were at church all the time, as were our kids,” Miller said. “We were completely involved. Then all of a sudden we didn’t see them at all.”

Sandra Kirkpatrick, a lay leader at the 30-member St. Stephen’s Episcopal, which held services on the lawn of a small house lent by a supporter, described it this way: “We just act like people who just know one another. We don’t socialize. If we run into one another at the Food Lion, we ask about one another’s kids and health, but very little to-and-fro-ing.”

After being caught in rain and heat, St. Stephen’s members built an enclosed porch for their services. There has been an upside to their struggles, Episcopal members said.

“The price was that our church experience continued on outside that building and was extremely rich,” said Paul Miller, Deborah’s husband. He was a worship leader at the Falls Church congregation before the split and continued working there, even though he chose to worship in the basement across the street with the few remaining Episcopalians.

With rifts so deep, the possibility of speedy healing seems unlikely.

“The other day someone asked me, ‘Wouldn’t it be wonderful if we could all worship together on Easter?’ ” Kirkpatrick said with a chuckle. “It would be, but that’s not going to happen.”