Homeless mothers who were evicted last week from an Oakland house where they were squatting plan to move back after speculators agreed to sell the property to a nonprofit organization, it was announced Monday.

Wedgewood Inc. will sell the home to the Oakland Community Land Trust, which buys and fixes up property for affordable housing. The group plans to allow women from the group Moms 4 Housing to return, Mayor Libby Schaaf announced.

The city helped negotiate the agreement with the land trust and Wedgewood after a public outcry following the evictions.

Oakland Mayor Libby Schaff outlined the new agreement between the City of Oakland, Wedgewood Properties and Moms4Housing in which the mothers will be able to purchase the home on Magnolia Street. Pete Suratos reports for NBC Bay Area on Monday, January 20, 2020.

“This is what happens when we organize, when people come together to build the beloved community,” Dominique Walker of Moms 4 Housing said in a statement on the holiday honoring civil rights leader Martin Luther King Jr. “Today we honor Dr. King’s radical legacy by taking Oakland back from banks and corporations.”

Wedgewood also agreed to work with the city to negotiate a right-of-first-refusal program for all its other Oakland properties, a city statement said.

Wedgewood will give the city, the land trust or other community groups the first chance to buy the homes “so they remain permanently affordable,” said Carroll Fife of the Alliance of Californians for Community Empowerment.

Last week, following a court order, two women from Moms 4 Housing were evicted from the vacant house on Magnolia Street that they and their children had illegally occupied since November. Sheriff’s deputies used a battering ram to enter and arrested the women.

The incident highlighted California’s severe housing shortage, soaring housing costs and a rising rate of homelessness. A one-night count of homeless in the San Francisco Bay Area city jumped 47% in two years to more than 4,000 last year.

The evicted women had said nobody should be homeless when investment companies are buying and fixing up properties to sell at a profit. Wedgewood, based in Southern California, has flipped 160 homes in Oakland over the past nine years, according to the San Francisco Chronicle.

The company bought the property in the distressed west Oakland at a foreclosure auction last year for just over $500,000.

The Oakland Community Land Trust will buy the home for a price not to exceed the appraised value,” said a statement from the office of Oakland Mayor Libby Schaaf.

The median house sales price in Oakland is about $750,000.

Breaking: @moms4housing will buy West #Oakland house through Oakland Community Land Trust. Wedgewood, the company that owns house, says it engaged in discussions with @GavinNewsom & @LibbySchaaf. A fitting day to announce this momentous agreement. #MLKDay #Moms4Housing pic.twitter.com/Cz1MOXMwQ2 — Melissa Colorado (@melissacolorado) January 20, 2020

Video: @LibbySchaaf says Wedgewood has made a historic agreement to change the way that they deal with #Oakland properties. She says she cannot condone unlawful acts but she can respect them. @nbcbayarea @moms4housing pic.twitter.com/WIAfz2cweB — Melissa Colorado (@melissacolorado) January 20, 2020

#Oakland Mayor @LibbySchaaf says she reached out to Wedgwood and had an hour long conversation with the company. Mayor: “we are not here to condone unlawful acts but we are here to respect them and to passionately advance what inspired them.” @nbcbayarea @moms4housing pic.twitter.com/UE4riabTQl — Melissa Colorado (@melissacolorado) January 20, 2020

Per #Oakland Mayor @LibbySchaaf, Wedgewood has agreed to offer community land trusts or the city the right of first refusal on ALL their Oakland properties. That means the homes can be purchased at fair market value & can be sold to low-income first-time homeowners. @nbcbayarea pic.twitter.com/gZWlAX6mx8 — Melissa Colorado (@melissacolorado) January 20, 2020

Monumental day for @moms4housing. Since covering this story, I haven’t seen Dominique Walker, co-founder of @moms4housing, smile this much. She is here with her children, who lived in the West #Oakland house until eviction. That house will eventually become theirs. @nbcbayarea pic.twitter.com/hIwai5fSxT — Melissa Colorado (@melissacolorado) January 20, 2020

#Oakland City Councilmember @nikki4oakland: “This is the start of a new civil rights movement.” She praised @moms4housing for inspiring this movement & inspiring new city housing policies. @nbcbayarea pic.twitter.com/wlPShKXMKd — Melissa Colorado (@melissacolorado) January 20, 2020

Wedgewood previously had refused to negotiate with the mothers’ group or the land trust but the eviction made national headlines and garnered strong political support.

“They’re representing tens of thousands of other mothers, families that are suffering,” Democratic Gov. Gavin Newsom said last week.

“Wedgewood is thankful for the outpouring of support for our company throughout the illegal occupation of our Oakland property. We appreciate the local, state and national support for property owners as well as the public’s support for non-violent discussion and action,” the company said in a statement Monday.

“We are honored and inspired to collaborate with the City of Oakland on reasonable, thoughtful, and organized actions to address the issue of homelessness and housing,” the company said.

Misty Cross, one of those evicted, said the group will continue pressing for affordable housing.

“We won’t stop until everyone is housed,” she said. “We want housing to be a human right.”