Boeing reported a massive second-quarter loss of $2.9 billion on Wednesday — its worst ever — as costs pile up for the aerospace giant while its flagship 737 Max jet remains grounded after two fatal crashes.

Shares of Boeing declined 3.1% from its previous close of $373.07, helping to drag down the Dow Jones Industrial Average.

Boeing lost $5.82 a share in the second quarter of 2019, with revenue falling sharply as well to $15.8 billion. Boeing's quarterly loss is the biggest in history for the company, according to FactSet, topping a $1.6 billion setback during the financial crisis in 2009.

The company delivered 104 fewer airplanes to customers in the second quarter compared with last year, as deliveries of the company's mass-produced 737 Max aircraft are halted. Boeing took a $4.9 billion charge last week because of the Max.

But while Boeing's performance remains under pressure, Melius Research analyst Carter Copeland told CNBC's "Squawk Box" that the results were not too bad considering the circumstances.

"The more you sift through the numbers ... this is actually a lot less scary than it could have been," Copeland said.

Boeing's earnings dropped nearly 275% from the same quarter last year, when the company earned $3.33 a share. Additionally, Boeing's revenue this quarter represents a drop of about 35% from the second quarter of 2018, when it brought in $24.8 billion.

"This is a defining moment for Boeing," Chairman and CEO Dennis Muilenburg said in a statement. He added that the company remains focused on safely returning the 737 Max to service.

The loss reflects last week's charge due to the worldwide grounding of its 737 Max planes after two fatal crashes killed 346 people. The charge amounted to $8.74 a share in earnings. In the earnings report, Boeing said the costs were "partially offset by higher defense and services volume."

The 737 Max has been grounded since mid-March. While Boeing is testing changes to the 737 Max's software, the company said that it remains unclear how long it will be until the airplane returns to flight.