WASHINGTON — Elizabeth Edwards is gravely ill and doctors have told her she has only weeks to live, according to a family friend who is among those who have gathered with Edwards at her North Carolina home.

The family issued a statement Monday that said doctors have told her that further treatment for her cancer would be unproductive.

The friend said Edwards was briefly hospitalized last week and received treatment, but doctors have now told her that she may only have up to a couple of months of life left. The friend spoke on condition of anonymity because of the personal details divulged.

Edwards’ estranged husband, former presidential candidate John Edwards, and their three children were at her side at the Chapel Hill home, the friend reported. Her sister, brother, nieces, nephews, former campaign advisers and other friends were also there. The friend said Elizabeth Edwards is not in pain and in good spirits despite the seriousness of her condition.

Edwards, a popular figure among Democratic activists as she campaigned with her husband in two presidential bids, posted on her Facebook page that she can’t express the love and gratitude she feels to those who have supported and inspired her.

“The days of our lives, for all of us, are numbered,” she wrote. “We know that. And yes, there are certainly times when we aren’t able to muster as much strength and patience as we would like. It’s called being human. But I have found that in the simple act of living with hope, and in the daily effort to have a positive impact in the world, the days I do have are made all the more meaningful and precious. And for that I am grateful.”

The 61-year-old Edwards separated from her husband after he admitted to an extramarital affair and fathering a child with a campaign videographer. Edwards has battled breast cancer since 2004, diagnosed in the final days of the campaign when her husband was the Democratic vice presidential nominee.