A passenger waiting to board a Bay Area Rapid Transit (BART) train in California last week was stopped by a transit agency police officer, detained and cited for eating a sandwich.

Videos of the now-viral confrontation were posted on Facebook on Friday by the man who was detained, identified as Steve Foster by television station ABC 7, which first reported the incident. His Facebook account uses the name Bill Gluckman.

Part of the incident, recorded by Foster's girlfriend at 8 a.m. local time Nov. 4, has been viewed on Facebook more than 2.6 million times and drew 40,000 comments as of Monday morning. It also prompted a protest over the weekend.

"Just out of curiosity.. has anybody ever got arrested and written a ticket for eating a breakfast sandwich on a Bart platform at 8:00 in the morning. Nobody? Just me? Okay," Foster wrote in the Facebook post.

The more than 10-minute-long video shows Foster on the Pleasant Hill platform eating a breakfast sandwich while the BART officer, identified on his name tag as D. McCormick, pulls on Foster's backpack.

"I'm not even on BART," Foster says as he waves his sandwich at the camera.

The officer responds: "I just explained that you are detained. Did I not? You are detained and you're not free to go."

Foster tells the officer to let him go and says: "You came over here and f----ed with me out of all these people."

"You're eating," the officer says.

"So what," Foster says, to which the officer replies: "It's against the law."

"So what," Foster says again, adding that it would be different if he was eating on a BART train.

"It's a violation of California law," the officer says. "I have a right to detain you."

During the video, Foster curses at the officer, tells him to let his bag go and says he will not provide his name because he says he has done nothing wrong.

Foster's girlfriend asks the officer why there is a store at the train station that sells food if it isn't legal to eat on the train platform and Foster tells the officer he eats on the platform every morning. The pair also asked the officer to call his supervisor and accuse him of targeting Foster.

"You're a f---in' weirdo," Foster says at one point in the video and later calls the officer racial and homophobic slurs.

When multiple officers arrive at the platform, Foster is handcuffed and told by police it is because he resisted arrest. NBC News attempted to reach Foster at a number listed for him and via Facebook but did not immediately hear back.

Foster was briefly handcuffed but released after identifying himself and issued a citation. On Saturday, dozens of protesters gathered at the Embarcadero station to stage an eat-in, titled "Brunch on Bart," as a show of support for Foster.

In a statement Monday, BART General Manager Bob Powers said he has seen the viral video and the police response and that he was "disappointed" with how the situation unfolded.

Powers said eating in the "paid area" is banned and there are multiple signs inside every station stating so. The concern with eating is related to cleanliness, Powers said, adding that this was not the case in the incident at the Pleasant Hill station last Monday.

According to Powers, the officer asked Foster not to eat while passing by on another call.

"It should have ended there, but it didn’t," Powers said. "When the officer walked by again and still saw him eating, he moved forward with the process of issuing him a citation."

Foster refused to provide identification and "cursed at and made homophobic slurs at the officer who remained calm through out the entire engagement," Powers said.

"Enforcement of infractions such as eating and drinking inside our paid area should not be used to prevent us from delivering on our mission to provide safe, reliable and clean transportation," Powers said.

Powers apologized in his statement to Foster and to "the public who have had an emotional reaction to the video" and said that he has spoken to the interim police chief about his feelings regarding the incident. Powers said an independent police auditor is conducting an investigation and will report his findings to the citizen review board.