Three weeks ago, the San Francisco Giants were one of the best teams in baseball. When they beat the New York Mets on June 8, they moved to 42-21, giving them the best record in the National League and pushing them a season-high 21 games over .500. They were on pace to win 108 games and run away with the NL West, leaving the Dodgers in the dust.

The Giants and Dodgers enter today in a virtual tie for first place. In three weeks, the Giants have blown a 9.5-game lead.

The question is simple — what happened??

For one, it’s incredibly hard to keep playing at the pace at which the Giants were playing over the course of a full season. They were likely going to slow down at some point, and regression to the mean was going to happen for guys like Michael Morse, who was carrying the offense for the better part of two months.

Morse started the year hitting .295/.351/.574 in April and May. He came into Sunday hitting .241/.284/.349 for the month of June. Pablo Sandoval is in the middle of his worst season since 2010, hitting just .266/.318/.420 as his plate discipline has taken a sudden downturn. The Giants having trouble piling up runs isn’t really all that new, but in June, the ability to string together a few hits in a row has seemingly left them completely. Among regulars, only Buster Posey, Brandon Crawford and Hunter Pence have done their fair share this month.

Then there’s the normally-excellent rotation, which has seen multiple pitchers hit rough patches at once. Tim Hudson entered June with an ERA of 1.92. Before allowing just two runs in 8+ innings on Sunday, Hudson’s June ERA was 4.30, with his WHIP for the month a scary 1.670. Tim Lincecum’s ERA for the month is at 4.88, and that’s after his recent no-hitter against San Diego. Ryan Vogelsong’s ERA this month is also over 5, but Matt Cain’s June may be most alarming of all — in 5 starts, the former staff ace has been tagged for a 5.46 ERA. Really, the only pitcher that’s maintained his performance throughout the month has been Madison Bumgarner.

There’s also the failing of the back end of the bullpen, something else that’s been a staple during the Giants’ recent five-year run. For two years, Sergio Romo was unhittable. He was an All-Star in 2013. In 2012, he won the World Series for San Francisco by freezing the best hitter of this generation.

This year, he’s lost control of his slider, and like everything else for the Giants, it all fell apart for him in June. After blowing three saves in his last five appearances — giving up a total of 9 runs in those outings — Romo lost his job as closer over the weekend. Closer-by-committee duties will be handled by Jeremy Affeldt and Santiago Casilla, with Romo being asked to cover the 8th or 7th inning until he returns to form.

If there’s good news for the Giants in any of this, it’s that it really can’t get much worse than this. For any team to go 4-15 in a three-week stretch takes a fair amount of bad luck, something that should correct itself. Looking at the big picture, they’re still 10 games over .500, even after getting swept at home this weekend in a four-game set against the surging Cincinnati Reds.

Yes, they’ve lost a massive division lead and now have their biggest rivals breathing down their necks, but at the halfway point of the season, “tied for first place in the division” isn’t a bad place to be. They also have three series against the Dodgers in the second half after going 7-3 against LA in the first half — there will be plenty of chances to keep the Dodgers at arms’ length if they can right the ship in July. Even if they slip behind the Dodgers in the standings, they still currently sit 4 games ahead of Pittsburgh, who’s sitting in third place in the wildcard standings. In other words, they still have a ways to fall before they’re outside of the playoff picture.

While the Giants lost again on Sunday, Hudson’s outing was a start in the right direction for the rotation. Brandon Belt is expected back in the lineup soon. And the Giants have never been shy about looking to improve the offense at the trade deadline, so it’s probably a fair expectation to see their name pop up in trade rumors in the coming weeks.

It’s been the month from hell in San Francisco, but there’s still plenty of time to make sure this is just a skid and not a full-scale collapse.