<?xml version='1.0' encoding='utf-8'?>
<FilingSummary>
  <Version>3.23.1</Version>
  <ProcessingTime/>
  <ReportFormat>html</ReportFormat>
  <ContextCount>85</ContextCount>
  <ElementCount>19</ElementCount>
  <EntityCount>1</EntityCount>
  <FootnotesReported>true</FootnotesReported>
  <SegmentCount>16</SegmentCount>
  <ScenarioCount>0</ScenarioCount>
  <TuplesReported>false</TuplesReported>
  <UnitCount>4</UnitCount>
  <MyReports>
    <Report instance="i23147_agm-def14a.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R1.htm</HtmlFileName>
      <LongName>00000001 - Document - Cover</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://farmermac.com/role/Cover</Role>
      <ShortName>Cover</ShortName>
      <MenuCategory>Cover</MenuCategory>
      <Position>1</Position>
    </Report>
    <Report instance="i23147_agm-def14a.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R2.htm</HtmlFileName>
      <LongName>995410 - Disclosure - Pay vs Performance Disclosure</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://xbrl.sec.gov/ecd/role/PvpDisclosure</Role>
      <ShortName>Pay vs Performance Disclosure</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>2</Position>
    </Report>
    <Report>
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <LongName>All Reports</LongName>
      <ReportType>Book</ReportType>
      <ShortName>All Reports</ShortName>
    </Report>
  </MyReports>
  <InputFiles>
    <File doctype="DEF 14A" original="i23147_agm-def14a.htm">i23147_agm-def14a.htm</File>
    <File>agm-20221231.xsd</File>
    <File>agm-20221231_def.xml</File>
    <File>agm-20221231_lab.xml</File>
    <File>agm-20221231_pre.xml</File>
  </InputFiles>
  <SupplementalFiles>
    <File>card-1.jpg</File>
    <File>card-2.jpg</File>
    <File>card-3.jpg</File>
    <File>card-4.jpg</File>
    <File>i23147001.jpg</File>
    <File>i23147002.jpg</File>
    <File>i23147003.jpg</File>
    <File>i23147004.jpg</File>
    <File>i23147004a.jpg</File>
    <File>i23147005.jpg</File>
    <File>i23147006.jpg</File>
    <File>i23147007.jpg</File>
    <File>i23147008.jpg</File>
    <File>i23147009.jpg</File>
    <File>i23147010.jpg</File>
    <File>i23147011.jpg</File>
    <File>i23147012.jpg</File>
    <File>i23147013.jpg</File>
    <File>i23147014.jpg</File>
    <File>i23147015.jpg</File>
    <File>i23147016.jpg</File>
    <File>i23147017.jpg</File>
    <File>i23147018.jpg</File>
    <File>i23147019.jpg</File>
    <File>i23147020.jpg</File>
    <File>i23147021.jpg</File>
    <File>i23147022.jpg</File>
    <File>i23147023.jpg</File>
    <File>i23147024.jpg</File>
    <File>i23147025.jpg</File>
    <File>i23147026.jpg</File>
    <File>i23147027.jpg</File>
    <File>i23147028.jpg</File>
    <File>i23147029.jpg</File>
    <File>i23147030.jpg</File>
    <File>i23147031.jpg</File>
    <File>i23147032.jpg</File>
    <File>i23147033.jpg</File>
    <File>i23147034.jpg</File>
    <File>i23147035.jpg</File>
    <File>i23147036.jpg</File>
    <File>i23147037.jpg</File>
    <File>i23147038.jpg</File>
    <File>i23147039.jpg</File>
    <File>i23147040.jpg</File>
    <File>i23147041.jpg</File>
    <File>i23147042.jpg</File>
    <File>i23147043.jpg</File>
    <File>i23147044.jpg</File>
    <File>i23147045.jpg</File>
  </SupplementalFiles>
  <BaseTaxonomies>
    <BaseTaxonomy items="3">http://fasb.org/us-gaap/2022</BaseTaxonomy>
    <BaseTaxonomy items="4">http://xbrl.sec.gov/dei/2022q4</BaseTaxonomy>
    <BaseTaxonomy items="129">http://xbrl.sec.gov/ecd/2022q4</BaseTaxonomy>
  </BaseTaxonomies>
  <HasPresentationLinkbase>true</HasPresentationLinkbase>
  <HasCalculationLinkbase>false</HasCalculationLinkbase>
</FilingSummary>
