A broken switch on Metro’s Red Line caused delays Wednesday morning for many commuters and comes as the agency is facing lower ridership levels.

At 6 a.m., Metro warned riders of “an unscheduled switch repair near Judiciary Square” and said crews were working to replace a “piece of rail at the switch point,” according to the news alert that went out. They expected it would take two hours, but trains didn’t return to normal service until 8:35 a.m., and there were backups of as much as 45 minutes as overcrowded trains pulled into stations.

As crews worked to replace the track, trains had to single track from Farragut North to Union Station. Metro warned customers to expect 30- to 40-minute delays in their commutes and to use the Green Line as an alternative.

But many riders said they didn’t know about the incident until they were already in the station and on a train. Others said they saw Metro’s warnings on screens in the station but still waited. Some train operators did give customers who were packed onto trains regular updates of the situation.

“I did hear on the radio that there were going to be 30-minute delays, but I was late already, so I just got on,” said Angelique Bradford as she stood in a packed Red Line train headed downtown.

Next to her, Javier Homet was checking his watch to see if he would make a 10 a.m. flight from Reagan National Airport to Phoenix for a business trip. He had boarded the train at Friendship Heights and saw the sign saying delays but thought he’d chance it.

After 30 minutes armpit-to-armpit with fellow passengers, he regretted it.

“I would have taken a taxi,” he said.

Standing next to him — oddly — was Metro Chief of Staff Barbara Richardson, who regularly commutes from the Friendship Heights stop. She asked if he’d seen Metro’s new screens in stations that tell of delays. He said he had, but was confused by the message of how long exactly the delay would be.

Richardson explained it is “hard to predict” at times exactly how long but that the warnings are estimations of how much time commuters should plan to add to their rides.

“It’s hard to predict for passengers,” Homet told her.

Christopher Amherst had to squeeze past standing-room only passengers to get out at Dupont Circle after having ridden in from Shady Grove. Usually, he said, he is in his office at 8:30 a.m. But he was 45 minutes late Wednesday.

“I’m looking forward to the bike share coming to Bethesda,” he said. “Then I don’t have to deal with the delays of the Red Line. I’d rather pay bike share than Metro. At least I can get to work on time.”

Riders stranded in trains and on platforms poured out their frustration on Facebook and Twitter, posting photos of the crowding and appealing to WMATA’s Twitter feed for answers about what went wrong and when it would be fixed.

“A switch problem? My train operator says a cracked rail is the cause of the #redline mess this morning,” tweeted one rider. Another rider responded, “they had both a switch problem AND a cracked rail!,” using the hashtag #doublewmatafail.

WMATA officials tweeted that the rail was not cracked, but that a piece of rail at the switch point at Judiciary Square had to be replaced.

The delays come as Metro is doing major work to its deteriorating system. Nearly every weekend, some stations are shut down or single tracking is implemented for some part of the system.

Metro ridership is down — the opposite from most major transit agencies across the country. Ridership was down 4.5 percent from July through October, compared with the same time period in 2011.

Last week at its January board committee meeting, Metro officials said the on-time performance across the rail system was 90.5 percent. On the Red Line, on time performance was 89.2 percent.

 Maggie Fazeli Fard also contributed to this post.