PORTLAND — The state on Thursday replaced the malfunctioning electrical switch that caused a drawbridge on the Casco Bay Bridge to become stuck in an upright position for more than two hours the day before.

Ted Talbot, a spokesman for the Maine Department of Transportation, said the bridge has been operating smoothly since the switch was replaced.

A large cargo ship carrying an electrical transformer bound for the Merrill Marine Terminal passed under the bridge on Thursday morning.

The malfunction, which occurred during the height of rush hour, forced police to shut down the northbound lanes of the bridge that connects Portland with South Portland for more than two hours on Wednesday.

Streets near the bridge became clogged with traffic during the closure, which began around 4 p.m. The bridge reopened at 6:15 p.m.