​WASHINGTON — On a Saturday morning three weeks ago, American radar detected rockets headed for a secret fire base of about 100 Marines in northern Iraq.

As warning sirens blared, a 27-year-old staff sergeant on his fifth combat tour rushed the Marines under his command to a bunker.

One rocket missed the Marines, but another exploded near the staff sergeant, Louis F. Cardin, while he was still outside. He was seriously wounded in the chest and died within the hour.

Less than 12 hours later, a Marine arrived at the home of Sergeant Cardin’s parents in Temecula, Calif., to inform them that their son had been killed.

It was the second time that an American service member had been killed in Iraq since President Obama resumed military operations there nearly two years ago.

In the days after Sergeant Cardin’s death, American military officials were forced to disclose why he and the Marines were at the base, how Marines would be used in the future and how many American troops were actually in Iraq. The new information illustrated how the conflict had quietly expanded far from the public’s view, and raised questions about Mr. Obama’s pledge to keep American troops out of combat there.

“Just because the commander in chief says there won’t be combat doesn’t mean that will be the case,” said Sergeant Cardin’s brother, Vincent Cardin, a former Army infantryman, in a telephone interview. “It doesn’t take much for someone to launch a rocket and start a fight when you’re in someone else’s country. If that’s not combat, I don’t know what is.”​From the beginning, Sergeant Cardin’s mission in Iraq was secret.

He was assigned to the Second Battalion, Sixth Marine Regiment, part of an expeditionary unit of roughly 2,200 Marines based on three Navy ships in the Persian Gulf. Last October, Sergeant Cardin left Camp Lejeune, N.C., for the passage across the Atlantic and the Mediterranean, and through the Suez Canal and the Strait of Hormuz.

By November, he and the Marines had arrived in the Gulf, where they remained aboard the ships as a quick-reaction ground force in case of a crisis nearby. They were to return to Lejeune this spring.

But just weeks before the Marines were scheduled to travel home, American military commanders decided to establish a small fire base in northern Iraq to help protect the nearly 5,000 Iraqi security forces who were working with dozens of American advisers at a larger base nearby, called Kara Soar.

The Americans moved in and out of Kara Soar as part of preparations to help the Iraqis invade Mosul, the largest city controlled by the Islamic State. At the time, the Islamic State, also known as ISIS or ISIL, was in command of territory about 10 miles from the Iraqi security forces, which allowed the militants to easily attack the Iraqis.

Over a month ago, Sergeant Cardin, an artillery specialist who enlisted in the Marines in 2006 after finishing high school in California, told his family that he was “going dark” from social media and email because he was being sent on an operation, his father, Fred Cardin, and his brother Vincent said in telephone interviews. Sergeant Cardin did not say where he was headed, they said.

Soon after, Sergeant Cardin, roughly 100 other Marines and four large artillery cannons were flown from the ships to Makhmur, an area about 50 miles south of Mosul, where Kara Soar is. Iraqi security forces had built several outposts in the empty fields around Kara Soar that were to be used as staging areas for their military operations.

The Marines took over one of the smallest of those outposts, which had a dirt berm as its protective barrier. Inside the outpost, holes were dug with backhoes for the cannons. The military named it Fire Base Bell.

It was primitive, but Sergeant Cardin had served in Iraq in 2007 and three times in Afghanistan during the worst of those wars.

The decision to send the Marines to the fire base was tightly held, Col. Steve Warren, a spokesman in Baghdad for American forces fighting the Islamic State, said last week. Commanders did not announce the movement because the Marines were in a dangerous area and they did not want to tip off the enemy, Colonel Warren said, but commanders planned to make the deployment public after the Marines had fully established themselves at the outpost.

But it was a departure from how the White House and Pentagon have handled similar deployments in Iraq over the past two years, when they have publicly disclosed when troops, including some Special Operations forces, were being sent into the country.Last week, White House officials cast the movement as part of an “advise and assist mission” intended to provide fire support and protection for the Iraqi forces fighting the Islamic State.

“This is very different from the combat mission with forward-deployed maneuver forces of the type we previously conducted in Iraq,” Emily Horne, a spokeswoman for the National Security Council, said in an email.

Still, Ms. Horne said, “this is a dangerous environment and ISIL is a determined enemy. There are absolutely risks in those kinds of operations, and no one knows that better than the brave men and women who serve in the region.”

However Sergeant Cardin’s mission was defined, the Marines began test-firing their cannons at the enemy shortly after they arrived. Islamic State fighters quickly figured out that the Marines were there.

On the morning of Saturday, March 19, just two days after Sergeant Cardin arrived at the base, a group of American military advisers visited the Iraqi security forces at Kara Soar, which is less than a mile from Fire Base Bell. Col. Ahmed Jasim Aatyia, an officer in the 15th Division of the Iraqi Army, was at Kara Soar with the Americans and recalled what happened at Fire Base Bell.

“Fifteen minutes after they left our compound, the base was attacked by Katyusha rockets,” he said.

At Bell, 40 minutes passed after the attack before a helicopter took Sergeant Cardin to a medical facility in Erbil. He was pronounced dead on arrival. Eight other Marines were wounded in the attacks, including three who were transported to an American military hospital in Landstuhl, Germany, and then to Walter Reed National Military Medical Center near Washington.

That morning in California, Sergeant Cardin’s parents, Fred and Mary Pat Cardin, were given a copy of their son’s casualty report by the Marine who came to their home to tell them of his death. Using Z for Zulu time and written in capital letters, the report said: “At approximately 0522Z, on 19 March 2016, SSGT Cardin was wounded in action from indirect fire while conducting operations in Iraq. SSGT Cardin sustained significant chest trauma and was recommended for immediate casevac. At approximately 0604Z, he was casevaced to a higher echelon of care in Erbil. En route, SSGT Cardin succumbed to his wounds and was pronounced deceased upon arrival.”

In a terse statement, Pentagon officials announced Sergeant Cardin’s death the same day, but did not name him: “A U.S. Marine providing force protection fire support at a recently established coalition fire base near Makhmur in northern Iraq was killed after coming under ISIL rocket fire.’’

The United States Central Command, which oversees American military operations in the Middle East, named Sergeant Cardin in a statement the next day. It was not until the following day, Monday, March 21, that Pentagon officials began to clarify what Colonel Warren called “confusion” about Sergeant Cardin’s death, his mission, the number of American troops in Iraq and why few knew that the Marines were headed into the country.

There are roughly 5,000 American service members in Iraq according to current Pentagon estimates, but the number often varies, sometimes daily, by hundreds. That number is higher than the cap the White House set last year, which limited the number of troops to be deployed to Iraq to 3,870. But under policies created by the military after the attacks of Sept. 11, 2001, service members who are planning to spend less than four months in a war zone are not counted.

Sergeant Cardin and the Marines were scheduled to be deployed in Iraq temporarily, so they did not count against the cap.At the height of the war in 2007, the United States had roughly 165,000 troops deployed in 500 bases and outposts across Iraq. Mr. Obama, who ran for president in 2008 vowing to end the United States’ involvement, fulfilled his pledge when he pulled all American troops out of the country in 2011. But as the Islamic State has strengthened its hold in the region in the past two years, Mr. Obama has sent thousands of American service members back in.

Since the attacks, Sergeant Cardin’s unit has remained at the base and been attacked by Islamic State fighters, military officials said. The Marines’ mission, the officials said, is to continue to support Iraqi forces as they advance on Islamic State fighters south of Mosul.The officials also said that bases similar to Fire Base Bell would probably be built as Iraqi security forces get closer to Mosul.​In the days after the attack, Fire Base Bell was renamed Kara Soar Counter Fire Complex. Two Defense Department officials, who were granted anonymity to discuss internal decision-making, said that the words “fire base” made it seem as if the Marines were in active combat.