In the wee hours of Sunday, Sept. 25, a handful of people on the streets of Portland were treated to a sight that they may have had a hard time explaining when the sun came up: Around 3 a.m., a 43-foot, 50-ton whale drove by.

The chance to study a critically endangered North Atlantic right whale up close is a rare opportunity. When the carcass of a big female was spotted floating off Boothbay Harbor, Lynda Doughty, executive director of Marine Mammals of Maine, was willing to go to any length to recover it. So she arranged to have the remains towed by a Coast Guard cutter for more than 20 miles, hefted onto a flatbed truck and driven inland, where they would be examined, then composted.

At 9 a.m. that Sunday, the whale lies strapped atop a logging truck at Benson Farm, a commercial composting facility in Gorham. I stand with a team of about 20 professionals and volunteers from eight research organizations from around the country, listening to Doughty recount the 18-hour effort to recover the carcass. I’ve helped dissect dolphins with the Marine Mammal Stranding Network in California, but this right whale is so much bigger. I’m trading my experienced labor for a chance to see this rare animal up close.

We are about to perform an animal autopsy, called a necropsy. It’s a titanic task.

Eddie Benson, the owner of Benson Farm, has offered the use of his employees and heavy machinery. Two front-end loaders — something like massive forklifts — and a large machine with a shovel arm, called an excavator, are at the team’s disposal.

The loaders push the whale off the flatbed and onto the ground. The team begins taking data that will help determine the cause of death. (The scene brings to mind an episode of “CSI,” except that the victim is a grossly oversize marine mammal.) Wraparound photos are made to construct a 3-D model of the bulky black body with its upturned jaw and stubby fins. Direct body measurements follow. The mood is a mix of empathy and professional curiosity.

One front-end loader lifts biologist Rob DiGiovanni 12 feet in the air above the whale’s girth to make incisions along her upturned flank. Most of the other volunteers surround the whale from the ground to cut the blubber into 3-foot-wide sections using long kitchen knives. I reach high above my head with both hands to cut into the whale’s belly. It sounds like slicing wet Velcro. A Benson Farm employee uses the excavator’s mechanical shovel to peel back strips of blubber as big as a grown man. Together, we cut the fat away from the body in a technique reminiscent of old whalers. (Of course, old whalers didn’t have tractors.)

Blubber is a versatile layer of fibrous fats that insulate the whale and act as energy storage. It smells a bit like rancid meat in honey. Blubber is tough, and it thickens throughout the summer as right whales feed on fatty crustaceans before migrating to warmer waters in the winter. The whales subsist on the energy stored in their blubber when food is scarce.

The blubber on this animal is 10 inches thick, about half of what it should be at this time of year. Still, a knife grows dull after only a few minutes of cutting. The team rotates through dozens of knives and sharpenings throughout the day, with one volunteer continually sharpening blades during the nine-hour necropsy.

It takes about four hours to remove enough blubber for the team to collect tissue samples, which they do according to a research wish list. Many of the organs are too rotten to study, but a few are viable enough to hint at the story of this whale.

Muscle and blubber samples are taken to look for contaminants including mercury. Feces are collected to examine hormone levels that will tell how long this whale experienced stress before she died. Baleen, the keratinous plates that right whales use to strain tiny crustaceans from the water, is collected for a process — stable isotope analysis — that can reveal where and when this whale found food.

Her empty uterus shows that she was not pregnant. Whiskers are plucked to study how right whales sense their environment. One scientist, clad in orange rubber fishing coveralls duct-taped to rubber boots, shows me an eye the size of a grapefruit that she has collected to investigate the shades or colors that right whales see. That study may help in redesigning fishing gear to be more visible to them.

The obvious cause of death for this whale is chronic entanglement in fishing gear. Green synthetic line was wrapped around her fins and head, preventing her from feeding for a long time. Thin blubber and very little stomach content or feces corroborate this. The vulnerable population of North Atlantic right whales hovers at around 500 animals. Most of them show scars from entanglements.

A 2016 research paper showed that entanglement in fishing gear has increased in recent years, causing poor health and lowered birth rates from chronic stress, and killing so many whales that the population is declining.

The number of vertical lines that can legally be attached to fishing gear has been trimmed back, but scientists say they think the reduction isn’t working well enough. The fishing line that was cut away from the whale’s mouth during the necropsy will be analyzed to determine which fishery it came from. Researchers hope that this information will help reduce future entanglements.

The only thing more difficult than performing a necropsy on a marine mammal of this size is figuring out what to do with the remains once all the hard work is done and the data collected.

“When a large whale shows up, the immediate question is ‘How are we going to get rid of this?’ ” Doughty says. “You can do the necropsy on the beach, but then we deal … with closing down clam flats and shellfish areas because of the bacteria seeping out from the animal,” Doughty says. Burying a whale on the beach requires the use of heavy farm equipment that may have trouble accessing a rocky beach site. Towing a gargantuan carcass out to sea doesn’t guarantee that it won’t wash up on another beach in an even worse state of decomposition, and may create a gooey hazard for unlucky boaters.

Landfills can’t accommodate a whale’s worth of organic material, and burying a whale inland poses its own problems. “While that tissue is buried underground … you have the animal break down and all those nutrients percolate right into groundwater. Then it’s pollution for someone’s drinking water,” says Mark King, an environmental specialist for the Maine Department of Environmental Protection. “Burial is absolutely off the table.”

King says that composting is the most viable option. He and Doughty had previously composted a smaller, dolphin-like pilot whale and a partially decomposed minke whale at Benson Farm. When the opportunity to necropsy this North Atlantic right whale came up, the former dairy in Gorham seemed like a perfect place to dispose of it afterward.

Performing the necropsy there provides scientists with one extremely valuable commodity: time. Dissecting a whale on the beach is a race against the tides, often precluding scientists from collecting all the tissue samples they want. But at Benson Farm, the team can take all day.

When the science is done, the peculiar business of composting a whale becomes Eddie Benson’s problem. He says that the basic science of “cooking” a whale is “a bit like Mother Nature’s been doing for millions of years, only we try to pull all the components together to do it just as quick as possible.” Benson heaps decomposing vegetation into bus-size mounds atop the whale’s discarded flesh, where microbes heat the compost and break it all down into nutrient-rich soil.

Maine DEP conducted studies in 2014 to establish standards for composting poultry infected with avian influenza. The agency determined that the material could be safely used as farm fertilizer after reaching a temperature of 131 degrees for about 28 days. Benson’s “secret compost recipe” cooks organic material at sustained temperatures of 150 degrees, more than enough to break down pathogens. In the end, a whale decomposes into safe, clean-smelling soil that can be used for gardening.

Benson usually sells his compost in bulk to farms or nurseries that then resell it as garden supplement. But compost derived from marine mammals poses a tricky issue. North Atlantic right whales are critically endangered and are protected under both the Endangered Species Act and the Marine Mammal Protection Act. Both federal laws prohibit the sale or trade of any body parts of protected animals.

So how long does it take for a right whale to become soil? Given the size of this animal, King says,”12 to 14 weeks.”

This whale had been given the name Egno. “She was first sighted as a calf in 2005 and had been photographed throughout her 11 years,” Doughty says. Egno was not entangled in fishing gear when she was last seen, in February of 2016. “For this animal to go from no gear in February to have such a severe entanglement and die from it in September is fast,” Doughty says. Egno died young: Members of her species can live for 70 years or more.

Doughty removed Egno’s bones from Benson Farm in late November. Officials have proposed displaying the skeleton at the Maine State Museum in a few years.

The rest of Egno has now been reduced to soil.

“If you dug through what’s left of the whale,” Benson said in a January follow-up interview, “you wouldn’t find any identifiable parts.”

That’s important because it’s illegal to sell any part of a marine mammal or an endangered species. Benson and Doughty don’t want to run afoul of the law, so they plan to take DNA samples of the compost in the spring to make certain it does not contain any of Egno’s genetic material — confirming she is gone. And then Benson plans to donate Egno’s compost to gardens and parks around southern Maine.

Chris Reeves, a freelance science writer in Rhode Island, specializes in wildlife conflicts and marine ecology.