The statute is short. Under 8 U.S.C. § 1447(b), "[i]f there is a failure to make a determination under section 1446 of this title before the end of the 120-day period after the date on which the examination is conducted under such section, the applicant may apply to the United States district court for the district in which the applicant resides for a hearing on the matter. Such court has jurisdiction over the matter and may either determine the matter or remand the matter, with appropriate instructions, to the Service to determine the matter." USCIS's own regulation says the same thing from the agency's side: a decision "shall be made at the time of the initial examination or within 120-days after the date of the initial examination," and USCIS "shall grant the application if the applicant has complied with all requirements for naturalization." 8 C.F.R. § 335.3(a).
"Examination" means the interview. The government has argued that the examination is a process that continues until background checks are complete, so that the 120 days never begins to run while the FBI or another agency is still working — a position adopted by a few early district-court decisions, most prominently Danilov v. Aguirre, 370 F. Supp. 2d 441 (E.D. Va. 2005). The Fifth Circuit rejected that reading by name in Walji v. Gonzales, 500 F.3d 432 (5th Cir. 2007), holding that the "examination" is a discrete event — the initial interview — and that the 120-day period runs from the date that interview concludes, whether or not a background check is still pending. The Fourth Circuit has described the clock the same way. The clock starts on the day you sit down with the officer.
Filing the petition shifts the case to the court. Every court of appeals to decide the question has held that a § 1447(b) petition vests the district court with exclusive jurisdiction over the application: United States v. Hovsepian, 359 F.3d 1144 (9th Cir. 2004) (en banc); Etape v. Chertoff, 497 F.3d 379 (4th Cir. 2007); Bustamante v. Napolitano, 582 F.3d 403 (2d Cir. 2009). Once the petition is on file, USCIS cannot grant or deny the application on its own unless and until the court remands it — and a decision the agency purports to issue after filing, without a remand, is without effect. This is the feature that makes § 1447(b) different from every other immigration delay suit. In a mandamus case the agency can moot the lawsuit by deciding, favorably or not, the moment it chooses. Here the agency must come to court to get the case back.
The court has two options, and it chooses. The statute says the court "may either determine the matter or remand the matter, with appropriate instructions." A court that determines the matter holds its own hearing on eligibility, and if you are eligible it can grant the application and administer the oath of allegiance in the courtroom — federal district courts are "eligible courts" authorized to administer the oath under 8 U.S.C. § 1421(b), and that is exactly what happened in Hovsepian, where the district court ordered the applications granted and swore the applicants in itself. In practice, most courts remand — the government almost always asks them to, usually representing that the holdup is nearly resolved — but they remand with instructions, typically a deadline by which USCIS must decide, and sometimes a provision that the court will decide the case itself if the deadline is missed. Courts have also declined to remand where USCIS shows no good cause for the delay or will not commit to a prompt decision. The instructions are where the leverage is, and negotiating them is much of the work.
Because Congress wrote a specific review channel with a specific deadline, the general delay statutes take a back seat. Courts have held that before day 120 there is no mandamus remedy for a post-interview naturalization delay, because § 1447(b) is the exclusive scheme, see Danilov, 370 F. Supp. 2d at 444–45; after day 120, § 1447(b) supplies the cause of action directly. That means none of the machinery that makes ordinary delay suits uncertain — the six-factor TRAC balancing, the argument that other applicants would be pushed back in line, the search for a forum receptive to delay claims — is part of a § 1447(b) case. There is no administrative remedy to exhaust first. Venue is fixed by statute in the district where you live.