(CNN) -- Two journalists covering civil unrest following a fatal shooting in Ferguson, Missouri, said they were briefly arrested Wednesday night inside a McDonald's in the community.

Wesley Lowery of The Washington Post and Ryan J. Reilly of The Huffington Post said on Twitter that they were arrested while they were doing work and then released within roughly 45 minutes. Neither was charged.

"This was very unnecessary," Lowery said in a telephone interview. He said he was never told why he and Reilly were detained, except that they were "trespassing" by being inside the fast-food restaurant.

Lowery recorded a portion of his interaction with an officer inside the McDonald's. In the video, which was published on The Washington Post's Web site, an officer is heard demanding that he "stop videotaping."

Journalists arrested in Ferguson

Hear police tapes from Ferguson shooting

Cops fire tear gas at protest crowds

Citizens and professional journalists generally have the right to record police activities.

Afterward, Reilly wrote in a Facebook post that a police officer "in full riot gear" "purposefully banged my head against the window on the way out and sarcastically apologized."

Reilly added, "I'm fine. But if this is the way these officers treat a white reporter working on a laptop who moved a little too slowly for their liking, I can't imagine how horribly they treat others. And if anyone thinks that the militarization of our police force isn't a huge issue in this country, I've got a story to tell you."

Lowery emphasized that he did not want his arrest to overshadow the ongoing protests in Ferguson or the treatment of the protesters. "I want this to be about the community," he said. "But this arrest is in some ways an anecdote of what's going on here."

The arrests came amid an already-tense situation between journalists and the authorities in Ferguson, the site of last Saturday's police shooting of an unarmed 18-year-old, Michael Brown.

There have been several reports of reporters and the camera crews being told to leave protest areas, but no reported arrests until Wednesday.

The Ferguson police chief, Thomas Jackson, told CNN he did not know who the arresting officers were. "We had a lot of different agencies out there," Jackson said.

At 11 p.m. CDT, Jackson said 18 people had been taken into custody on Wednesday, including the two reporters.

Elsewhere in the area on Wednesday evening, a number of reporters said they were doused with tear gas when authorities tried to disperse crowds. Ash-Har Quraishi, a correspondent for Al Jazeera America who previously worked for CNN, said his crew was in a place "we believed to be safe" when people started running toward them.

"Rubber bullets were fired on us, and then a canister," he said. "We had to retreat into the neighborhood."

In a statement about the "worsening situation in Ferguson," Missouri Gov. Jay Nixon urged law enforcement agencies "to keep the peace and respect the rights of residents and the press during this difficult time."

Apparently, in America, in 2014, police can manhandle you, take you into custody, put you in cell & then open the door like it didn't happen

Officials at both The Washington Post and The Huffington Post issued statements that assailed the reporter arrests.

Martin Baron, the executive editor of The Washington Post, said in a statement Wednesday night that "there was absolutely no justification" for Lowery's arrest.

Baron noted that the reporter was "illegally instructed to stop taking video of officers. Then he followed officers' instructions to leave a McDonald's -- and after contradictory instructions on how to exit, he was slammed against a soda machine and then handcuffed. That behavior was wholly unwarranted and an assault on the freedom of the press to cover the news."

Ryan Grim, The Huffington Post's Washington bureau chief, noted in a statement that Reilly "has reported multiple times from Guantanamo Bay." According to Grim, Reilly "said that the police resembled soldiers more than officers, and treated those inside the McDonald's as 'enemy combatants.'"

Grim concluded his statement by saying, "Police militarization has been among the most consequential and unnoticed developments of our time, and it is now beginning to affect press freedom."