"Interacting online seems to be healthy when the online activity is moderate and complements interactions offline," said first author William Hobbs, who worked on the study as a UC San Diego doctoral student and is now a postdoctoral fellow at Northeastern University.
"It is only on the extreme end, spending a lot of time online with little evidence of being connected to people otherwise, that we see a negative association."
The research confirms what scientists have known for a long time about the offline world - people who have stronger social networks live longer.
But it documents for the first time that what happens online may also make a difference.
"Happily, for almost all Facebook users, what we found is balanced use and a lower risk of mortality," said James Fowler, professor of political science in the UC San Diego Division of Social Sciences.
The researchers matched California Facebook users with vital records from the California Department of Public Health.
After being automatically matched on name and birth date, the data was de-identified and aggregated.
The researchers compared the activity of those still living to those who had died over a period of six months.
All of those studied were born between 1945 and 1989, and all the comparisons were made between people of similar age and gender.
The researchers found those who are on Facebook live longer than those who are not.
In a given year, the average Facebook user is about 12 per cent less likely to die than someone who does not use the site.
The researchers noted this was their crudest measure, and it may be due to social or economic differences between the user and non-user groups.
Facebook users who accepted the most friendships also lived the longest.
Those on Facebook with highest levels of offline social integration - as measured by posting more photos, which suggests face-to-face social activity - had the greatest longevity.
People with average or large social networks, in the top 50 to 30 per cent, lived longer than those in the lowest 10 - a finding consistent with classic studies of offline relationships and longevity.
"The association between longevity and social networks was identified by Lisa Berkman in 1979 and has been replicated hundreds of times since," said Professor Fowler.
"In fact, a recent meta-analysis suggests the connection may be very strong.
"Social relationships seem to be as predictive of lifespan as smoking, and more predictive than obesity and physical inactivity.
"We're adding to that conversation by showing that online relationships are associated with longevity, too."
The researchers hope subsequent research leads to a better understanding of what kinds of online social experiences are protective of health.
"What happens on Facebook and other social networks is very likely important," Professor Fowler said.
"But what we can't do at this time is give either individual or larger policy recommendations based on this first work."